mirror of
				https://github.com/avatao-content/frontend-tutorial-framework
				synced 2025-11-04 12:42:55 +00:00 
			
		
		
		
	Trigger change detection explicitly after WebIDE content is updated
This makes human sized stack traces go away ¯\_(ツ)_/¯
This commit is contained in:
		@@ -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();
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user