Skip to content

Commit

Permalink
kiss sync filter
Browse files Browse the repository at this point in the history
  • Loading branch information
debris committed Jul 10, 2015
1 parent b13ed4e commit 7183775
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lib/web3/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,28 +139,29 @@ var Filter = function (options, methods, formatter, callback) {
this.callbacks = [];
this.pollFilters = [];
this.formatter = formatter;
this.implementation.newFilter(this.options, function(error, id){
if(error) {
self.callbacks.forEach(function(cb){
cb(error);
});
} else {

if (callback) {
this.implementation.newFilter(this.options, function(error, id) {
if (error) {
return self.callbacks.forEach(function(cb){
cb(error);
});
}
self.filterId = id;

// get filter logs for the already existing watch calls
self.callbacks.forEach(function(cb){
getLogsAtStart(self, cb);
});

if(self.callbacks.length > 0)
pollFilter(self);

// start to watch immediately
if(callback) {
return self.watch(callback);
}
}
});

return self.watch(callback);
});
} else {
this.filterId = this.implementation.newFilter(this.options);
}
};

Filter.prototype.watch = function (callback) {
Expand Down

0 comments on commit 7183775

Please sign in to comment.