Merge pull request #7 from status-im/avoid_duplicate_updates

only trigger property watcher when value actually changes
This commit is contained in:
Iuri Matias 2019-08-20 11:27:01 -04:00 committed by GitHub
commit bb335aa4cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 427 additions and 346 deletions

View File

@ -1,5 +1,5 @@
const { fromEvent, interval, ReplaySubject } = require('rxjs');
const { throttle, filter } = require('rxjs/operators');
const { throttle, filter, distinctUntilChanged } = require('rxjs/operators');
const loki = require('lokijs')
const Events = require('events')
@ -164,8 +164,7 @@ class EventSyncer {
}])
})
// TODO: add distinctUntilChanged
return sub;
return sub.pipe(distinctUntilChanged());
}
}

View File

@ -151,6 +151,12 @@ async function run() {
await SimpleStorageContract.methods.set(100).send({ from: accounts[0], gas: 4700000 })
console.dir("set 200")
await SimpleStorageContract.methods.set2(200).send({ from: accounts[0] })
console.dir("set 200")
await SimpleStorageContract.methods.set2(200).send({ from: accounts[0] })
console.dir("set 300")
await SimpleStorageContract.methods.set(300).send({ from: accounts[0] })
console.dir("set 300")
await SimpleStorageContract.methods.set(300).send({ from: accounts[0] })
console.dir("set 300")
await SimpleStorageContract.methods.set(300).send({ from: accounts[0] })

762
yarn.lock

File diff suppressed because it is too large Load Diff