ModelN/backbone.geppetto — pull request #64 by creynders (2014-09-05 11:37:14+00:00)
Title: Add Context#executeCommand

This is the last one, promised ;)

I added an `executeCommand` method to the context. It's something I realise I could/would use sometimes. For instance in my current project I have a pretty complex control flow state machiny-thing. Basically it's a controller. The reason why I don't rely on a commands/events mapping is because I find it far more clear to have all of this centralised instead of having to track the flow through a dozen or so commands. Anyway, in my controller there are however sites where I _do_ want to execute a command, since the command centralises some complex update mechanic for instance, so ATM I simply dispatch dedicated events, which are mapped to the relevant commands, but actually would like it more to being able to execute the command directly with

```js
this.context.executeCommand(ComplexUpdateMechanicCommand);
```

`executeCommand` accepts a second parameter, named "event", which is an object with `eventName` and `eventData` members. E.g.

```js
this.context.executeCommand(ComplexUpdateMechanicCommand, {
eventName : "update:complex:mechanic",
eventData: {
importantStuff: "Holy shizzles!"
}
} );
```