mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-07-12 15:46:22 +00:00
Update services according to the new API
This commit is contained in:
@ -3,25 +3,20 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { WebSocketService } from './websocket.service';
|
||||
import { LogMessage } from '../message-types/log-message';
|
||||
import { ProcessLogCommand } from '../message-types/process-log-command';
|
||||
import { config } from '../config';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { LogMessage } from '../message-types/log-message';
|
||||
import { CommandMessage } from '../message-types/command-message';
|
||||
|
||||
@Injectable()
|
||||
export class ProcessLogService {
|
||||
newLogs = new BehaviorSubject<LogMessage>(config.console.defaultLogs);
|
||||
showLiveLogs = config.console.showLiveLogs;
|
||||
|
||||
command_handlers = {
|
||||
'new_log': this.newLogsHandler.bind(this)
|
||||
};
|
||||
|
||||
constructor(private webSocketService: WebSocketService) {
|
||||
this.webSocketService.connect();
|
||||
this.webSocketService.observeKey<CommandMessage>('processlog').subscribe(
|
||||
(event) => this.command_handlers[event.data.command](event.data)
|
||||
this.webSocketService.observeKey<ProcessLogCommand>('log.new').subscribe(
|
||||
(event) => this.newLogsHandler(event)
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user