-
-
Save ckarlof/170a89ce92febd29a6cf to your computer and use it in GitHub Desktop.
WebChannel refactor
This file contains 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
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