import { Event } from './event'; import { Error } from './error'; import { Console } from './console'; const limit = 20; export class LogViewModel { sessionId: string; error: Error; consoleEntries: Array = new Array(); events: Array = new Array(); constructor(sessionId: string) { this.sessionId = sessionId; } public addError(error: Error) { this.error = error; } public addEvent(event: Event) { this.events.push(event); if (this.events.length >= limit) { this.events.splice(0, 1); } } public addConsoleEntry(entry: Console) { this.consoleEntries.push(entry); } public clear() { this.error = null; this.events.splice(0, limit); this.consoleEntries.splice(0, limit); } }