milltest/Market.js
Martin Donnelly e6b7c987d8 init
2020-08-11 12:55:43 +01:00

21 lines
444 B
JavaScript

const { Subject, interval } = require('rxjs');
class Market {
constructor(sellers) {
this.sellers = sellers;
this.observable = new Subject();
this.observable.subscribe({
next: (v) => this.tick()
});
interval(5000).subscribe(v => this.observable.next(v));
}
tick(){
this.sellers.forEach(seller => {
seller.tick()
});
}
}
exports.Market = Market;