mirror of https://github.com/status-im/web3.js.git
changes in filter.js (not yet working)
This commit is contained in:
parent
c2d9c1a6f1
commit
edfb874527
|
@ -434,8 +434,6 @@ module.exports = {
|
||||||
var web3 = require('./web3'); // jshint ignore:line
|
var web3 = require('./web3'); // jshint ignore:line
|
||||||
var abi = require('./abi');
|
var abi = require('./abi');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should be called when we want to call / transact some solidity method from javascript
|
* 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
|
* it returns an object which has same methods available as solidity contract description
|
||||||
|
@ -544,13 +542,9 @@ var Filter = function(options, impl) {
|
||||||
this.impl = impl;
|
this.impl = impl;
|
||||||
this.callbacks = [];
|
this.callbacks = [];
|
||||||
|
|
||||||
var self = this;
|
this.id = impl.newFilter(options);
|
||||||
this.promise = impl.newFilter(options);
|
web3.on(impl.changed, this.id, this.trigger.bind(this));
|
||||||
this.promise.then(function (id) {
|
web3.provider.startPolling({call: impl.changed, args: [this.id]}, this.id);
|
||||||
self.id = id;
|
|
||||||
web3.on(impl.changed, id, self.trigger.bind(self));
|
|
||||||
web3.provider.startPolling({call: impl.changed, args: [id]}, id);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// alias for changed*
|
/// alias for changed*
|
||||||
|
@ -560,10 +554,7 @@ Filter.prototype.arrived = function(callback) {
|
||||||
|
|
||||||
/// gets called when there is new eth/shh message
|
/// gets called when there is new eth/shh message
|
||||||
Filter.prototype.changed = function(callback) {
|
Filter.prototype.changed = function(callback) {
|
||||||
var self = this;
|
this.callbacks.push(callback);
|
||||||
this.promise.then(function(id) {
|
|
||||||
self.callbacks.push(callback);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// trigger calling new message from people
|
/// trigger calling new message from people
|
||||||
|
@ -575,20 +566,14 @@ Filter.prototype.trigger = function(messages) {
|
||||||
|
|
||||||
/// should be called to uninstall current filter
|
/// should be called to uninstall current filter
|
||||||
Filter.prototype.uninstall = function() {
|
Filter.prototype.uninstall = function() {
|
||||||
var self = this;
|
this.impl.uninstallFilter(this.id);
|
||||||
this.promise.then(function (id) {
|
web3.provider.stopPolling(this.id);
|
||||||
self.impl.uninstallFilter(id);
|
web3.off(impl.changed, this.id);
|
||||||
web3.provider.stopPolling(id);
|
|
||||||
web3.off(impl.changed, id);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// should be called to manually trigger getting latest messages from the client
|
/// should be called to manually trigger getting latest messages from the client
|
||||||
Filter.prototype.messages = function() {
|
Filter.prototype.messages = function() {
|
||||||
var self = this;
|
return this.impl.getMessages(this.id);
|
||||||
return this.promise.then(function (id) {
|
|
||||||
return self.impl.getMessages(id);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// alias for messages
|
/// alias for messages
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -23,8 +23,6 @@
|
||||||
var web3 = require('./web3'); // jshint ignore:line
|
var web3 = require('./web3'); // jshint ignore:line
|
||||||
var abi = require('./abi');
|
var abi = require('./abi');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should be called when we want to call / transact some solidity method from javascript
|
* 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
|
* it returns an object which has same methods available as solidity contract description
|
||||||
|
|
|
@ -31,13 +31,9 @@ var Filter = function(options, impl) {
|
||||||
this.impl = impl;
|
this.impl = impl;
|
||||||
this.callbacks = [];
|
this.callbacks = [];
|
||||||
|
|
||||||
var self = this;
|
this.id = impl.newFilter(options);
|
||||||
this.promise = impl.newFilter(options);
|
web3.on(impl.changed, this.id, this.trigger.bind(this));
|
||||||
this.promise.then(function (id) {
|
web3.provider.startPolling({call: impl.changed, args: [this.id]}, this.id);
|
||||||
self.id = id;
|
|
||||||
web3.on(impl.changed, id, self.trigger.bind(self));
|
|
||||||
web3.provider.startPolling({call: impl.changed, args: [id]}, id);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// alias for changed*
|
/// alias for changed*
|
||||||
|
@ -47,10 +43,7 @@ Filter.prototype.arrived = function(callback) {
|
||||||
|
|
||||||
/// gets called when there is new eth/shh message
|
/// gets called when there is new eth/shh message
|
||||||
Filter.prototype.changed = function(callback) {
|
Filter.prototype.changed = function(callback) {
|
||||||
var self = this;
|
this.callbacks.push(callback);
|
||||||
this.promise.then(function(id) {
|
|
||||||
self.callbacks.push(callback);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// trigger calling new message from people
|
/// trigger calling new message from people
|
||||||
|
@ -62,20 +55,14 @@ Filter.prototype.trigger = function(messages) {
|
||||||
|
|
||||||
/// should be called to uninstall current filter
|
/// should be called to uninstall current filter
|
||||||
Filter.prototype.uninstall = function() {
|
Filter.prototype.uninstall = function() {
|
||||||
var self = this;
|
this.impl.uninstallFilter(this.id);
|
||||||
this.promise.then(function (id) {
|
web3.provider.stopPolling(this.id);
|
||||||
self.impl.uninstallFilter(id);
|
web3.off(impl.changed, this.id);
|
||||||
web3.provider.stopPolling(id);
|
|
||||||
web3.off(impl.changed, id);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// should be called to manually trigger getting latest messages from the client
|
/// should be called to manually trigger getting latest messages from the client
|
||||||
Filter.prototype.messages = function() {
|
Filter.prototype.messages = function() {
|
||||||
var self = this;
|
return this.impl.getMessages(this.id);
|
||||||
return this.promise.then(function (id) {
|
|
||||||
return self.impl.getMessages(id);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// alias for messages
|
/// alias for messages
|
||||||
|
|
Loading…
Reference in New Issue