picked watch change
This commit is contained in:
parent
dc0f2318bf
commit
2215e7c3af
|
@ -2106,7 +2106,8 @@ var Filter = function (options, methods, formatter) {
|
|||
|
||||
Filter.prototype.watch = function (callback) {
|
||||
this.callbacks.push(callback);
|
||||
var self = this;
|
||||
var self = this,
|
||||
requestmanager = RequestManager.getInstance();
|
||||
|
||||
var onMessage = function (error, messages) {
|
||||
if (error) {
|
||||
|
@ -2123,7 +2124,12 @@ Filter.prototype.watch = function (callback) {
|
|||
});
|
||||
};
|
||||
|
||||
RequestManager.getInstance().startPolling({
|
||||
// call getFilterLogs on start
|
||||
if (!utils.isString(this.options)) {
|
||||
this.get(onMessage);
|
||||
}
|
||||
|
||||
requestmanager.startPolling({
|
||||
method: this.implementation.poll.call,
|
||||
params: [this.filterId],
|
||||
}, this.filterId, onMessage, this.stopWatching.bind(this));
|
||||
|
@ -2135,12 +2141,23 @@ Filter.prototype.stopWatching = function () {
|
|||
this.callbacks = [];
|
||||
};
|
||||
|
||||
Filter.prototype.get = function () {
|
||||
var logs = this.implementation.getLogs(this.filterId);
|
||||
Filter.prototype.get = function (callback) {
|
||||
var self = this;
|
||||
if(utils.isFunction(callback)) {
|
||||
this.implementation.getLogs(this.filterId, function(err, res){
|
||||
if(!err) {
|
||||
callback(null, res.map(function (log) {
|
||||
return self.formatter ? self.formatter(log) : log;
|
||||
}));
|
||||
} else
|
||||
callback(err);
|
||||
});
|
||||
} else {
|
||||
var logs = this.implementation.getLogs(this.filterId);
|
||||
return logs.map(function (log) {
|
||||
return self.formatter ? self.formatter(log) : log;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Filter;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -2106,7 +2106,8 @@ var Filter = function (options, methods, formatter) {
|
|||
|
||||
Filter.prototype.watch = function (callback) {
|
||||
this.callbacks.push(callback);
|
||||
var self = this;
|
||||
var self = this,
|
||||
requestmanager = RequestManager.getInstance();
|
||||
|
||||
var onMessage = function (error, messages) {
|
||||
if (error) {
|
||||
|
@ -2123,7 +2124,12 @@ Filter.prototype.watch = function (callback) {
|
|||
});
|
||||
};
|
||||
|
||||
RequestManager.getInstance().startPolling({
|
||||
// call getFilterLogs on start
|
||||
if (!utils.isString(this.options)) {
|
||||
this.get(onMessage);
|
||||
}
|
||||
|
||||
requestmanager.startPolling({
|
||||
method: this.implementation.poll.call,
|
||||
params: [this.filterId],
|
||||
}, this.filterId, onMessage, this.stopWatching.bind(this));
|
||||
|
@ -2135,12 +2141,23 @@ Filter.prototype.stopWatching = function () {
|
|||
this.callbacks = [];
|
||||
};
|
||||
|
||||
Filter.prototype.get = function () {
|
||||
var logs = this.implementation.getLogs(this.filterId);
|
||||
Filter.prototype.get = function (callback) {
|
||||
var self = this;
|
||||
if(utils.isFunction(callback)) {
|
||||
this.implementation.getLogs(this.filterId, function(err, res){
|
||||
if(!err) {
|
||||
callback(null, res.map(function (log) {
|
||||
return self.formatter ? self.formatter(log) : log;
|
||||
}));
|
||||
} else
|
||||
callback(err);
|
||||
});
|
||||
} else {
|
||||
var logs = this.implementation.getLogs(this.filterId);
|
||||
return logs.map(function (log) {
|
||||
return self.formatter ? self.formatter(log) : log;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Filter;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -69,7 +69,8 @@ var Filter = function (options, methods, formatter) {
|
|||
|
||||
Filter.prototype.watch = function (callback) {
|
||||
this.callbacks.push(callback);
|
||||
var self = this;
|
||||
var self = this,
|
||||
requestmanager = RequestManager.getInstance();
|
||||
|
||||
var onMessage = function (error, messages) {
|
||||
if (error) {
|
||||
|
@ -86,7 +87,12 @@ Filter.prototype.watch = function (callback) {
|
|||
});
|
||||
};
|
||||
|
||||
RequestManager.getInstance().startPolling({
|
||||
// call getFilterLogs on start
|
||||
if (!utils.isString(this.options)) {
|
||||
this.get(onMessage);
|
||||
}
|
||||
|
||||
requestmanager.startPolling({
|
||||
method: this.implementation.poll.call,
|
||||
params: [this.filterId],
|
||||
}, this.filterId, onMessage, this.stopWatching.bind(this));
|
||||
|
@ -98,12 +104,23 @@ Filter.prototype.stopWatching = function () {
|
|||
this.callbacks = [];
|
||||
};
|
||||
|
||||
Filter.prototype.get = function () {
|
||||
var logs = this.implementation.getLogs(this.filterId);
|
||||
Filter.prototype.get = function (callback) {
|
||||
var self = this;
|
||||
if(utils.isFunction(callback)) {
|
||||
this.implementation.getLogs(this.filterId, function(err, res){
|
||||
if(!err) {
|
||||
callback(null, res.map(function (log) {
|
||||
return self.formatter ? self.formatter(log) : log;
|
||||
}));
|
||||
} else
|
||||
callback(err);
|
||||
});
|
||||
} else {
|
||||
var logs = this.implementation.getLogs(this.filterId);
|
||||
return logs.map(function (log) {
|
||||
return self.formatter ? self.formatter(log) : log;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Filter;
|
||||
|
|
Loading…
Reference in New Issue