chaplinjs/chaplin — pull request #340 by paulmillr (2012-12-26 17:33:22+00:00)
Title: Implement mediator.pub-sub as refs to Backbone.on-off.

As per discussion in gh-334:

1. Backbone implemented global events in 0.9.9.
2. Our `EventBroker` preserves context of `this`, which means If we will switch to `mediator.subscribe = Backbone.on`, **nothing** will change for those who use `EventBroker` for pub-sub.
3. A while after bb-1.0, users will be confused that our `publishEvent` doesn’t work with BB global events.

See the code:

```coffeescript
initialize: ->
super
@subscribeEvent 'stuff1', @stuff1
mediator.subscribe 'stuff2', @stuff2
Backbone.on 'stuff3', @stuff3

setTimeout =>
@publishEvent 'stuff1', 'hello'
@publishEvent 'stuff2', 'hello'
Backbone.trigger 'stuff3', 'hello'
, 5000

stuff1: ->
console.log 'stuff1', this, arguments

stuff2: ->
console.log 'stuff2', this, arguments

stuff3: ->
console.log 'stuff3', this, arguments
```

outputs:

```
stuff1 ["hello"]
stuff2 ["hello"]
stuff3 ["hello"]
```

and it stays the same if I do this

```
mediator.subscribe = Backbone.on
mediator.unsubscribe = Backbone.off
mediator.publish = Backbone.trigger
```