diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-22 04:54:03 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-22 04:54:03 +0800 |
commit | edfb874527160cee14cca931377e55187b874cbe (patch) | |
tree | 6b98cb423beb1d4c3a54a9c14b3a3458a65df898 /lib | |
parent | c2d9c1a6f12822a08300bbafb66227d8d33ae73b (diff) | |
download | dexon-edfb874527160cee14cca931377e55187b874cbe.tar dexon-edfb874527160cee14cca931377e55187b874cbe.tar.gz dexon-edfb874527160cee14cca931377e55187b874cbe.tar.bz2 dexon-edfb874527160cee14cca931377e55187b874cbe.tar.lz dexon-edfb874527160cee14cca931377e55187b874cbe.tar.xz dexon-edfb874527160cee14cca931377e55187b874cbe.tar.zst dexon-edfb874527160cee14cca931377e55187b874cbe.zip |
changes in filter.js (not yet working)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/contract.js | 2 | ||||
-rw-r--r-- | lib/filter.js | 29 |
2 files changed, 8 insertions, 23 deletions
diff --git a/lib/contract.js b/lib/contract.js index 1cd4151fd..aa4188d40 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -23,8 +23,6 @@ var web3 = require('./web3'); // jshint ignore:line var abi = require('./abi'); - - /** * This method should be called when we want to call / transact some solidity method from javascript * it returns an object which has same methods available as solidity contract description diff --git a/lib/filter.js b/lib/filter.js index 4a82babb9..76e67e9c1 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -31,13 +31,9 @@ var Filter = function(options, impl) { this.impl = impl; this.callbacks = []; - var self = this; - this.promise = impl.newFilter(options); - this.promise.then(function (id) { - self.id = id; - web3.on(impl.changed, id, self.trigger.bind(self)); - web3.provider.startPolling({call: impl.changed, args: [id]}, id); - }); + this.id = impl.newFilter(options); + web3.on(impl.changed, this.id, this.trigger.bind(this)); + web3.provider.startPolling({call: impl.changed, args: [this.id]}, this.id); }; /// alias for changed* @@ -47,10 +43,7 @@ Filter.prototype.arrived = function(callback) { /// gets called when there is new eth/shh message Filter.prototype.changed = function(callback) { - var self = this; - this.promise.then(function(id) { - self.callbacks.push(callback); - }); + this.callbacks.push(callback); }; /// trigger calling new message from people @@ -62,20 +55,14 @@ Filter.prototype.trigger = function(messages) { /// should be called to uninstall current filter Filter.prototype.uninstall = function() { - var self = this; - this.promise.then(function (id) { - self.impl.uninstallFilter(id); - web3.provider.stopPolling(id); - web3.off(impl.changed, id); - }); + this.impl.uninstallFilter(this.id); + web3.provider.stopPolling(this.id); + web3.off(impl.changed, this.id); }; /// should be called to manually trigger getting latest messages from the client Filter.prototype.messages = function() { - var self = this; - return this.promise.then(function (id) { - return self.impl.getMessages(id); - }); + return this.impl.getMessages(this.id); }; /// alias for messages |