frontend-tutorial-framework/src/app/services/fsmupdate.service.ts

21 lines
694 B
TypeScript

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<string>();
public in_accepted_state = new Subject<boolean>();
constructor(private websocketService: WebSocketService) {}
public init() {
this.websocketService.connect();
this.websocketService.observeAll<FSMUpdateMessage>('fsm.update').subscribe((message) => {
this.current_state.next(message.current_state);
this.in_accepted_state.next(message.in_accepted_state);
});
}
}