# HG changeset patch # User Lucas Thompson # Date 1477639734 -3600 # Node ID 953932e9ba827817d2a122923f2d4df36ac56b98 # Parent dcfcba8fde0aa12c5083fef8605cc4408447920c Remove zone injection from app.component and move to where the event is emitted in audio-file-open.component. diff -r dcfcba8fde0a -r 953932e9ba82 src/app/app.component.ts --- a/src/app/app.component.ts Thu Oct 27 17:48:23 2016 +0100 +++ b/src/app/app.component.ts Fri Oct 28 08:28:54 2016 +0100 @@ -1,4 +1,4 @@ -import {Component, Inject, NgZone} from '@angular/core'; +import {Component, Inject} from '@angular/core'; import {MailService} from "./mail.service"; @Component({ @@ -14,8 +14,7 @@ constructor( private mail: MailService, - @Inject('piper-server-uri') private serverUri, - private zone: NgZone + @Inject('piper-server-uri') private serverUri ) {} onUpdate(id, text) { @@ -23,10 +22,8 @@ } onAudioLoaded(buffer: AudioBuffer) { - this.zone.run(() => { // TODO why the f does this only recognise changes immediately (and not the next tick) inside zone.run? - this.audioBuffer = buffer; - this.count++; - }); + this.audioBuffer = buffer; + this.count++; } testRef() { diff -r dcfcba8fde0a -r 953932e9ba82 src/app/audio-file-open/audio-file-open.component.ts --- a/src/app/audio-file-open/audio-file-open.component.ts Thu Oct 27 17:48:23 2016 +0100 +++ b/src/app/audio-file-open/audio-file-open.component.ts Fri Oct 28 08:28:54 2016 +0100 @@ -1,6 +1,6 @@ import { Component, OnInit, ViewChild, ElementRef, Output, - EventEmitter + EventEmitter, NgZone } from '@angular/core'; interface AudioContextConstructor { @@ -24,7 +24,7 @@ private audioContext: AudioContext; - constructor() { + constructor(private zone: NgZone) { this.audioLoaded = new EventEmitter(); // TODO make a service which provides the AudioContext? @@ -40,7 +40,9 @@ const reader: FileReader = new FileReader(); reader.onload = (event: any) => { this.audioContext.decodeAudioData(event.target.result, buffer => { - this.audioLoaded.emit(buffer); + this.zone.run(() => { + this.audioLoaded.emit(buffer); + }); }); }; reader.readAsArrayBuffer(files[0]);