diff src/app/app.component.ts @ 16:7e3ab6f8792f

Rough waveform loading, issues exist regarding communicating changes from child components (unless using the current workaround with explicit zone running)... investigating.
author Lucas Thompson <dev@lucas.im>
date Thu, 27 Oct 2016 17:08:57 +0100
parents b4a1e0a67389
children ff964b28a272
line wrap: on
line diff
--- a/src/app/app.component.ts	Thu Oct 27 14:44:37 2016 +0100
+++ b/src/app/app.component.ts	Thu Oct 27 17:08:57 2016 +0100
@@ -1,4 +1,4 @@
-import {Component, Inject} from '@angular/core';
+import {Component, Inject, NgZone} from '@angular/core';
 import {MailService} from "./mail.service";
 
 @Component({
@@ -9,12 +9,28 @@
 export class AppComponent {
   title = 'Ugly';
 
+  count = 0;
+  audioBuffer: AudioBuffer = undefined;
+
   constructor(
     private mail: MailService,
-    @Inject('piper-server-uri') private serverUri
+    @Inject('piper-server-uri') private serverUri,
+    private zone: NgZone
   ) {}
 
   onUpdate(id, text) {
     this.mail.update(id, text);
   }
+
+  onAudioLoaded(buffer: AudioBuffer) {
+    this.zone.run(() => { // TODO why the f does this only recognise changes immediately (and not the next tick) inside zone.run?
+      console.log("audio loaded");
+      this.audioBuffer = buffer;
+      this.count++;
+    });
+  }
+
+  testRef() {
+    this.count++;
+  }
 }