https://github.com/moonwave99/backbone.station
A mixin for making life with Backbone.Radio even easier.
https://github.com/moonwave99/backbone.station
Last synced: about 2 months ago
JSON representation
A mixin for making life with Backbone.Radio even easier.
- Host: GitHub
- URL: https://github.com/moonwave99/backbone.station
- Owner: moonwave99
- Created: 2015-04-14T14:47:37.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-15T12:29:02.000Z (about 11 years ago)
- Last Synced: 2026-02-08T11:47:26.017Z (4 months ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# backbone.station
A mixin for making life with [Backbone.Radio](https://github.com/marionettejs/backbone.radio) even easier.
## Instructions
In order not to fill initialisers with `Backbone.Radio.channel('app').comply( 'do:smth', this.action, this)` all over the place, you can now put all the configuration in two `complyTo` and `replyTo` hashes like this:
var MyView = Backbone.View.extend(_.extend({}, Backbone.Station, {
complyTo: {
channelName: {
'commandName' : 'someHandler',
'anotherCommandName' : function(params){ ... }
},
anotherChannelName: { ... }
},
replyTo: {
channelName: {
'requestName' : ...
}
},
...
'someHandler' : function(params){ ... }
}));
You just need to call the `_initChannels` method in the initialiser, like this:
initialize: function(options){
this._initChannels.call(this, 'channelName', 'anotherChannelName');
}
In order to remove listeners on view/object disposal, run `_unsubscribe`:
onDestroy: function(){
this._unsubscribe.call(this);
}