diff options
author | Jeffrey Wilcke <obscuren@users.noreply.github.com> | 2014-10-31 04:35:40 +0800 |
---|---|---|
committer | Jeffrey Wilcke <obscuren@users.noreply.github.com> | 2014-10-31 04:35:40 +0800 |
commit | aca9a41fcf38ae42ab72b663b6fdc4ecd9c7a7b9 (patch) | |
tree | 066a6280876d2c6c05788989d1f0610be37b4b46 /qt.js | |
parent | eef4cd1b64c38e3327dbe7f1b70a60b01ce9cbed (diff) | |
parent | cb607b4911711501a8e70db0fe2148c51272c719 (diff) | |
download | go-tangerine-aca9a41fcf38ae42ab72b663b6fdc4ecd9c7a7b9.tar go-tangerine-aca9a41fcf38ae42ab72b663b6fdc4ecd9c7a7b9.tar.gz go-tangerine-aca9a41fcf38ae42ab72b663b6fdc4ecd9c7a7b9.tar.bz2 go-tangerine-aca9a41fcf38ae42ab72b663b6fdc4ecd9c7a7b9.tar.lz go-tangerine-aca9a41fcf38ae42ab72b663b6fdc4ecd9c7a7b9.tar.xz go-tangerine-aca9a41fcf38ae42ab72b663b6fdc4ecd9c7a7b9.tar.zst go-tangerine-aca9a41fcf38ae42ab72b663b6fdc4ecd9c7a7b9.zip |
Merge pull request #1 from debris/master
Http JSON-RPC provider, http polling, little refactor, whisper
Diffstat (limited to 'qt.js')
-rw-r--r-- | qt.js | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -1,12 +1,22 @@ (function() { - var QtProvider = function() {}; + var QtProvider = function() { + this.handlers = []; + + var self = this; + navigator.qt.onmessage = function (message) { + self.handlers.forEach(function (handler) { + handler.call(self, JSON.parse(message)); + }); + } + }; + QtProvider.prototype.send = function(payload) { navigator.qt.postData(JSON.stringify(payload)); }; Object.defineProperty(QtProvider.prototype, "onmessage", { set: function(handler) { - navigator.qt.onmessage = handler; + this.handlers.push(handler); }, }); |