{"action":"created","issue":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2324","labels_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2324/labels{/name}","comments_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2324/comments","events_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2324/events","html_url":"https://github.com/marionettejs/backbone.marionette/issues/2324","id":57524415,"number":2324,"title":"Add api for binding an object to a radio channel","user":{"login":"jasonLaster","id":254562,"avatar_url":"https://avatars.githubusercontent.com/u/254562?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonLaster","html_url":"https://github.com/jasonLaster","followers_url":"https://api.github.com/users/jasonLaster/followers","following_url":"https://api.github.com/users/jasonLaster/following{/other_user}","gists_url":"https://api.github.com/users/jasonLaster/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonLaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonLaster/subscriptions","organizations_url":"https://api.github.com/users/jasonLaster/orgs","repos_url":"https://api.github.com/users/jasonLaster/repos","events_url":"https://api.github.com/users/jasonLaster/events{/privacy}","received_events_url":"https://api.github.com/users/jasonLaster/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/labels/major","name":"major","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/milestones/12","html_url":"https://github.com/marionettejs/backbone.marionette/milestones/v3.0.0","labels_url":"https://api.github.com/repos/marionettejs/backbone.marionette/milestones/12/labels","id":630229,"number":12,"title":"v3.0.0","description":"","creator":{"login":"jmeas","id":2322305,"avatar_url":"https://avatars.githubusercontent.com/u/2322305?v=3","gravatar_id":"","url":"https://api.github.com/users/jmeas","html_url":"https://github.com/jmeas","followers_url":"https://api.github.com/users/jmeas/followers","following_url":"https://api.github.com/users/jmeas/following{/other_user}","gists_url":"https://api.github.com/users/jmeas/gists{/gist_id}","starred_url":"https://api.github.com/users/jmeas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmeas/subscriptions","organizations_url":"https://api.github.com/users/jmeas/orgs","repos_url":"https://api.github.com/users/jmeas/repos","events_url":"https://api.github.com/users/jmeas/events{/privacy}","received_events_url":"https://api.github.com/users/jmeas/received_events","type":"User","site_admin":false},"open_issues":21,"closed_issues":60,"state":"open","created_at":"2014-04-15T03:06:11Z","updated_at":"2015-03-10T23:55:25Z","due_on":null,"closed_at":null},"comments":34,"created_at":"2015-02-12T21:45:24Z","updated_at":"2015-03-13T14:46:07Z","closed_at":null,"body":"Radio is a fantastic eventbus that we should make as easy to use as possible from within Mn. The api, I have in mind is `bindToChannel`, with some great defaults for things like Routes and Application\r\n\r\n\r\n```js\r\nvar FormService = Marionette.Class.extend({\r\n  logChannel: {\r\n    'event info' :'onInfo'\r\n  },\r\n\r\n  formChannel: {\r\n    'event invalid': 'onInvalid',\r\n    'command submit' : 'submitForm'\r\n  },\r\n\r\n  initialize: function() {\r\n    this.bindToChannel('log', this.logChannel);\r\n    this.bindToChannel('form', this.formChannel);\r\n  }\r\n})\r\n```\r\n\r\n```js\r\nheaderRoute = Marionette.Route.extend({\r\n  channel: {\r\n    'command user:show' : 'userShow'\r\n  }\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/comments/79004668","html_url":"https://github.com/marionettejs/backbone.marionette/issues/2324#issuecomment-79004668","issue_url":"https://api.github.com/repos/marionettejs/backbone.marionette/issues/2324","id":79004668,"user":{"login":"jfairbank","id":195580,"avatar_url":"https://avatars.githubusercontent.com/u/195580?v=3","gravatar_id":"","url":"https://api.github.com/users/jfairbank","html_url":"https://github.com/jfairbank","followers_url":"https://api.github.com/users/jfairbank/followers","following_url":"https://api.github.com/users/jfairbank/following{/other_user}","gists_url":"https://api.github.com/users/jfairbank/gists{/gist_id}","starred_url":"https://api.github.com/users/jfairbank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfairbank/subscriptions","organizations_url":"https://api.github.com/users/jfairbank/orgs","repos_url":"https://api.github.com/users/jfairbank/repos","events_url":"https://api.github.com/users/jfairbank/events{/privacy}","received_events_url":"https://api.github.com/users/jfairbank/received_events","type":"User","site_admin":false},"created_at":"2015-03-13T14:46:07Z","updated_at":"2015-03-13T14:46:07Z","body":"I've been playing with this by implementing something similar at work. So far I'm liking the idea of something like:\r\n\r\n```js\r\nvar MyObject = BaseObject.extend({\r\n  channelNames: ['foo', 'bar', 'baz'],\r\n\r\n  // or radioEvents\r\n  channelEvents: {\r\n    'foo save:user': '_savedUser',\r\n    'bar start': '_startedBar'\r\n  },\r\n\r\n  channelCommands: {\r\n    'foo delete:user': '_deleteUser'\r\n  },\r\n\r\n  initialize() {\r\n    this.getChannel('foo') === Radio.channel('foo');\r\n  },\r\n\r\n  _savedUser() {\r\n    this.channelCommand('bar', 'stop');\r\n    this.channelTrigger('baz', 'save:user');\r\n  },\r\n\r\n  ...\r\n});\r\n```\r\n\r\nSo, it's basically a similar API to what has already been suggested for handlers as well as some helpers like `channelCommand`, `channelTrigger`, `channelRequest`, and `getChannel`. Using the helpers has grown on me instead of grabbing a channel at the top of a module or using the Radio API directly. That somewhat decouples the idea of what event bus is driving these channels underneath."}}