import { Injectable } from '@angular/core'; import { WebSocketService } from './websocket.service'; import { FSMUpdateMessage } from '../message-types/fsm-update-message'; import { Subject } from 'rxjs'; @Injectable() export class FSMUpdateService { public current_state = new Subject(); public in_accepted_state = new Subject(); constructor(private websocketService: WebSocketService) {} public init() { this.websocketService.connect(); this.websocketService.observeAll('fsm.update').subscribe((message) => { this.current_state.next(message.current_state); this.in_accepted_state.next(message.in_accepted_state); }); } }