ModelN/backbone.geppetto — pull request #22 by creynders (2013-08-01 11:29:03+00:00)
Title: adds Context#execute and passes payloads as parameters instead of single...

... object

Proposed changes:

1. Adds an `execute` method to the context, to allow direct sequential synchronous execution of commands:
```js

context.execute([FooCommand, BarCommand], 'baz', 'qux'); //last two are payload
```
1. Modifies how payloads are passed to commands and callbacks:
in case of

```js

context.dispatch('foo', 'bar', 'baz', 'qux');
```
* commands are injected with an `event` object with following structure:

```js

{
name: 'foo',
data: [ 'bar', 'baz', 'qux' ]
}
```
* commands also receive the payload as arguments to the `execute` function:

```js

function execute(bar, baz, qux)
```
* callbacks receive the payload as arguments, just as a command's `execute` function

1. Throws concrete error when a command has no `execute` method

Then, a bit of the reasoning:

I opted for `event` with `name` and `data` to keep the modification as small as possible. I.e. if you'd like to update your <=0.6.2 commands to this version, "all" you'll need to do is swap `this.eventName` with `this.event.name` and `this.eventData` with `this.event.data`

A major breaking change is the fact that event names are no longer passed to callbacks. Do you think this is a problem? Commands still have access to the event name through the `event` object, but views won't. Would this be something you can live with? Personally I never, ever need event names in my handlers, but YMMV.

BTW I had to drop the blanket coverage treshold to 97, otherwise it failed. Do you think this is due to the introduction of the pseudo-private `_execute` method?

see #18
see #20