Matteo Scandolo | 63e43eb | 2016-12-14 14:18:53 -0800 | [diff] [blame] | 1 | /// <reference path="../../../../typings/index.d.ts"/> |
| 2 | |
| 3 | import {Subject} from 'rxjs/Rx'; |
| 4 | import {IWSEvent, IWSEventService} from '../websocket/global'; |
| 5 | |
| 6 | export class SynchronizerStore { |
| 7 | static $inject = ['WebSocket']; |
| 8 | private _notifications: Subject<IWSEvent> = new Subject(); |
| 9 | constructor( |
| 10 | private webSocket: IWSEventService |
| 11 | ) { |
| 12 | this.webSocket.list() |
| 13 | .filter((e: IWSEvent) => { |
| 14 | return e.msg.changed_fields.indexOf('backend_status') > -1; |
| 15 | }) |
| 16 | .subscribe( |
| 17 | (event: IWSEvent) => { |
| 18 | this._notifications.next(event); |
| 19 | } |
| 20 | ); |
| 21 | } |
| 22 | |
| 23 | query() { |
| 24 | return this._notifications.asObservable(); |
| 25 | } |
| 26 | } |