aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/assets/ext/filter.js
blob: 20f0b36a30856284fcc537dad3d3a20bb8e57a4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var Filter = function(eth, options) {
    this.callbacks = {};
    this.seed = Math.floor(Math.random() * 1000000);
    this.eth = eth;

    eth.registerFilter(options, this.seed);
};

Filter.prototype.changed = function(callback) {
    var cbseed = Math.floor(Math.random() * 1000000);
    this.eth.registerFilterCallback(this.seed, cbseed);

    var self = this;
    message.connect(function(messages, seed, callbackSeed) {
        if(seed ==  self.seed && callbackSeed == cbseed) {
            callback.call(self, messages);
        }
    });
};

Filter.prototype.uninstall = function() {
    eth.uninstallFilter(this.seed)
}