Skip to content

Instantly share code, notes, and snippets.

@ckarlof
Created July 11, 2014 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckarlof/170a89ce92febd29a6cf to your computer and use it in GitHub Desktop.
Save ckarlof/170a89ce92febd29a6cf to your computer and use it in GitHub Desktop.
WebChannel refactor
WebChannelBroker is a internal implementation detail of WebChannels
registerChannel(channel)
unregisterChannel(channel)
WebChannel
constructor(channelId, origin) -> WebChannel
channelId
origin
_deliver(message, sender) ->
listen(callback)
this._listenCallback = callback;
WebChannelBroker.registerChannel(this);
stopListening()
this._listenCallback = null;
WebChannelBroker.unregisterListener(this);
send(message, [target])
let wc = new WebChannel(channelId, origin)
let cb = function(channelId, message, sender) {
wc.send({....}, sender);
}
wc.listen(cb)
.......
wc.stopListening()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment