ng-sake #9

メトロノーム川上@saruyama_monki

ngDoCheck

Lifecycle hook that is called when Angular dirty checks a directive.

How To Use

@Component({selector: 'my-cmp', template: `...`})
class MyComponent implements DoCheck {
  ngDoCheck() {
    // ...
  }
}

https://angular.io/api/core/DoCheck

Where did I using it

Looper has 8 services

Analyze

Destination

Gain

Mic

Play

Recording

Sound

UserMedia

Where did I using it

Service is controling state

Mic Service

ON / OFF state

Where did I using it

ngDoCheck is controling that

ngDoCheck code

    ngDoCheck() {

        ...

        // mic ON / OFF
        if (this.service_mic.isMic === true && !this.service_mic.stream && this.service_mic.isUserMedia === false) {
            this.service_mic.on((source) => {
                this.service_gain.connect(source);
            });

        } else if (this.service_mic.isMic === false && this.service_mic.stream) {
            this.service_mic.off();
            this.service_gain.disconnect(this.service_mic.source);
        }

        ...

Thank you

ng-sake#9

By Kawakami Kazuyoshi

ng-sake#9

  • 665