view 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 source
import {Component, Inject, NgZone} from '@angular/core';
import {MailService} from "./mail.service";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'Ugly';

  count = 0;
  audioBuffer: AudioBuffer = undefined;

  constructor(
    private mail: MailService,
    @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++;
  }
}