This commit is contained in:
Iuri Matias 2019-06-03 12:08:54 -04:00
parent 6b6c74118f
commit 242fa9c8cf
2 changed files with 4 additions and 6 deletions

View File

@ -1,7 +1,6 @@
const { Observable, fromEvent, interval, Subject, ReplaySubject } = require('rxjs'); const { fromEvent, interval, ReplaySubject } = require('rxjs');
const { throttle, throttleTime, map, distinctUntilChanged, filter, average, reduce, count, scan } = require('rxjs/operators'); const { throttle, filter } = require('rxjs/operators');
const loki = require('lokijs') const loki = require('lokijs')
//const db = new loki('loki.json', {autosave: true, autoload: true})
class EventSyncer { class EventSyncer {

View File

@ -1,7 +1,6 @@
// var Web3 = require('web3') // var Web3 = require('web3')
const Events = require('events') const Events = require('events')
const { Observable, fromEvent, interval, Subject } = require('rxjs'); const { map, scan } = require('rxjs/operators');
const { throttle, throttleTime, map, distinctUntilChanged, filter, average, reduce, count, scan } = require('rxjs/operators');
const Simulator = require('./simulator.js') const Simulator = require('./simulator.js')
const EventSyncer = require('./eventSyncer.js') const EventSyncer = require('./eventSyncer.js')
@ -23,7 +22,7 @@ function run() {
let mymap = map(arr => arr.reduce((acc, current) => acc + current, 0) / arr.length) let mymap = map(arr => arr.reduce((acc, current) => acc + current, 0) / arr.length)
eventSyncer.trackEvent('contractEvent', ((x) => x.from === "0x123")).pipe(map(x => x.rating), myscan, mymap).subscribe((v) => { eventSyncer.trackEvent('contractEvent', ((x) => x.from === "0x123")).pipe(map(x => x.rating), myscan, mymap).subscribe((v) => {
console.dir("current value is " + v) console.dir("current average is " + v)
}) })
const simulator = new Simulator(events); const simulator = new Simulator(events);