Trigger change detection explicitly after WebIDE content is updated

This makes human sized stack traces go away ¯\_(ツ)_/¯
This commit is contained in:
Bálint Bokros 2018-02-15 11:21:14 +01:00
parent 882899ee9c
commit 8e5f402519

View File

@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import 'brace/mode/python';
import 'brace/mode/javascript';
@ -22,7 +22,8 @@ export class WebideComponent implements OnInit {
files: string[];
saveButtonState = 'DIRTY';
constructor(private webSocketService: WebSocketService) { }
constructor(private webSocketService: WebSocketService,
private changeDetectorRef: ChangeDetectorRef) { }
ngOnInit() {
this.webSocketService.observeAnchor<SourceCode>(this.anchor_id).subscribe((event) => {
@ -33,6 +34,8 @@ export class WebideComponent implements OnInit {
if (event.data.command === 'write') { this.saveButtonState = 'SAVED'; }
if (event.data.command === 'reload') { this.requestCode(); }
this.changeDetectorRef.detectChanges();
});
this.requestCode();
}