aboutsummaryrefslogtreecommitdiffstats
path: root/qt.js
diff options
context:
space:
mode:
authorJeffrey Wilcke <obscuren@users.noreply.github.com>2014-10-31 04:35:40 +0800
committerJeffrey Wilcke <obscuren@users.noreply.github.com>2014-10-31 04:35:40 +0800
commitaca9a41fcf38ae42ab72b663b6fdc4ecd9c7a7b9 (patch)
tree066a6280876d2c6c05788989d1f0610be37b4b46 /qt.js
parenteef4cd1b64c38e3327dbe7f1b70a60b01ce9cbed (diff)
parentcb607b4911711501a8e70db0fe2148c51272c719 (diff)
downloadgo-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.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/qt.js b/qt.js
index 39c0a89a9..1b146c30d 100644
--- a/qt.js
+++ b/qt.js
@@ -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);
},
});