Created
January 9, 2016 17:32
-
-
Save Teino1978-Corp/2f07245cb183bcf8cc25 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var source = Backbone.Radio.channel('source'); | |
var proxy = Backbone.Radio.channel('proxy'); | |
// 1 to 1 mapping | |
proxy.proxyEvents(source, { | |
'source:foo': 'proxy:foo' | |
}); | |
proxy.on('proxy:foo', console.log); | |
source.trigger('source:foo', 1); // triggers proxy:foo on proxy, prints 1 | |
//mapping with prefixing, probably too opinionated for most use cases | |
proxy.proxyEvents(source, ['bar'], { | |
srcPrefix: 'source', | |
proxyPrefix: 'proxy' | |
}); | |
proxy.on('proxy:bar', console.log); | |
source.trigger('source:foo', 1); // triggers proxy:bar on proxy, prints 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment