mirror of https://github.com/status-im/web3.js.git
fixed #51
This commit is contained in:
parent
03661d3bc2
commit
26561e4767
|
@ -826,7 +826,7 @@ var filter = function(options, implementation, formatter) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
implementation.startPolling(filterId, onMessages);
|
implementation.startPolling(filterId, onMessages, uninstall);
|
||||||
|
|
||||||
var changed = function (callback) {
|
var changed = function (callback) {
|
||||||
callbacks.push(callback);
|
callbacks.push(callback);
|
||||||
|
@ -1221,8 +1221,8 @@ var requestManager = function() {
|
||||||
provider = p;
|
provider = p;
|
||||||
};
|
};
|
||||||
|
|
||||||
var startPolling = function (data, pollId, callback) {
|
var startPolling = function (data, pollId, callback, uninstall) {
|
||||||
polls.push({data: data, id: pollId, callback: callback});
|
polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});
|
||||||
};
|
};
|
||||||
|
|
||||||
var stopPolling = function (pollId) {
|
var stopPolling = function (pollId) {
|
||||||
|
@ -1234,6 +1234,13 @@ var requestManager = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var reset = function () {
|
||||||
|
polls.forEach(function (poll) {
|
||||||
|
poll.uninstall(poll.id);
|
||||||
|
});
|
||||||
|
polls = [];
|
||||||
|
};
|
||||||
|
|
||||||
var poll = function () {
|
var poll = function () {
|
||||||
polls.forEach(function (data) {
|
polls.forEach(function (data) {
|
||||||
var result = send(data.data);
|
var result = send(data.data);
|
||||||
|
@ -1251,7 +1258,8 @@ var requestManager = function() {
|
||||||
send: send,
|
send: send,
|
||||||
setProvider: setProvider,
|
setProvider: setProvider,
|
||||||
startPolling: startPolling,
|
startPolling: startPolling,
|
||||||
stopPolling: stopPolling
|
stopPolling: stopPolling,
|
||||||
|
reset: reset
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1656,11 +1664,11 @@ var setupProperties = function (obj, properties) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var startPolling = function (method, id, callback) {
|
var startPolling = function (method, id, callback, uninstall) {
|
||||||
web3.manager.startPolling({
|
web3.manager.startPolling({
|
||||||
method: method,
|
method: method,
|
||||||
params: [id]
|
params: [id]
|
||||||
}, id, callback);
|
}, id, callback, uninstall);
|
||||||
};
|
};
|
||||||
|
|
||||||
var stopPolling = function (id) {
|
var stopPolling = function (id) {
|
||||||
|
@ -1739,6 +1747,12 @@ var web3 = {
|
||||||
},
|
},
|
||||||
setProvider: function (provider) {
|
setProvider: function (provider) {
|
||||||
web3.manager.setProvider(provider);
|
web3.manager.setProvider(provider);
|
||||||
|
},
|
||||||
|
|
||||||
|
/// Should be called to reset state of web3 object
|
||||||
|
/// Resets everything except manager
|
||||||
|
reset: function () {
|
||||||
|
web3.manager.reset();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -83,7 +83,7 @@ var filter = function(options, implementation, formatter) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
implementation.startPolling(filterId, onMessages);
|
implementation.startPolling(filterId, onMessages, uninstall);
|
||||||
|
|
||||||
var changed = function (callback) {
|
var changed = function (callback) {
|
||||||
callbacks.push(callback);
|
callbacks.push(callback);
|
||||||
|
|
|
@ -57,8 +57,8 @@ var requestManager = function() {
|
||||||
provider = p;
|
provider = p;
|
||||||
};
|
};
|
||||||
|
|
||||||
var startPolling = function (data, pollId, callback) {
|
var startPolling = function (data, pollId, callback, uninstall) {
|
||||||
polls.push({data: data, id: pollId, callback: callback});
|
polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});
|
||||||
};
|
};
|
||||||
|
|
||||||
var stopPolling = function (pollId) {
|
var stopPolling = function (pollId) {
|
||||||
|
@ -70,6 +70,13 @@ var requestManager = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var reset = function () {
|
||||||
|
polls.forEach(function (poll) {
|
||||||
|
poll.uninstall(poll.id);
|
||||||
|
});
|
||||||
|
polls = [];
|
||||||
|
};
|
||||||
|
|
||||||
var poll = function () {
|
var poll = function () {
|
||||||
polls.forEach(function (data) {
|
polls.forEach(function (data) {
|
||||||
var result = send(data.data);
|
var result = send(data.data);
|
||||||
|
@ -87,7 +94,8 @@ var requestManager = function() {
|
||||||
send: send,
|
send: send,
|
||||||
setProvider: setProvider,
|
setProvider: setProvider,
|
||||||
startPolling: startPolling,
|
startPolling: startPolling,
|
||||||
stopPolling: stopPolling
|
stopPolling: stopPolling,
|
||||||
|
reset: reset
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
10
lib/web3.js
10
lib/web3.js
|
@ -80,11 +80,11 @@ var setupProperties = function (obj, properties) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var startPolling = function (method, id, callback) {
|
var startPolling = function (method, id, callback, uninstall) {
|
||||||
web3.manager.startPolling({
|
web3.manager.startPolling({
|
||||||
method: method,
|
method: method,
|
||||||
params: [id]
|
params: [id]
|
||||||
}, id, callback);
|
}, id, callback, uninstall);
|
||||||
};
|
};
|
||||||
|
|
||||||
var stopPolling = function (id) {
|
var stopPolling = function (id) {
|
||||||
|
@ -163,6 +163,12 @@ var web3 = {
|
||||||
},
|
},
|
||||||
setProvider: function (provider) {
|
setProvider: function (provider) {
|
||||||
web3.manager.setProvider(provider);
|
web3.manager.setProvider(provider);
|
||||||
|
},
|
||||||
|
|
||||||
|
/// Should be called to reset state of web3 object
|
||||||
|
/// Resets everything except manager
|
||||||
|
reset: function () {
|
||||||
|
web3.manager.reset();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue