only trigger property watcher when value actually changes

This commit is contained in:
Iuri Matias 2019-08-20 11:20:54 -04:00
parent 0a4811ce6b
commit e90dfa8a59
3 changed files with 427 additions and 346 deletions

View File

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

View File

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

762
yarn.lock

File diff suppressed because it is too large Load Diff