Skip to content

Commit

Permalink
fixup! TEMP - Enable AOT always
Browse files Browse the repository at this point in the history
  • Loading branch information
gkalpak committed Sep 25, 2020
1 parent 98876d2 commit 3104c3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
@@ -1,6 +1,6 @@
// #docplaster
// #docregion vc
import { AfterViewInit, ViewChild } from '@angular/core';
import { ViewChild } from '@angular/core';
// #docregion lv
import { Component } from '@angular/core';
import { CountdownTimerComponent } from './countdown-timer.component';
Expand Down Expand Up @@ -37,19 +37,12 @@ export class CountdownLocalVarParentComponent { }
`,
styleUrls: ['../assets/demo.css']
})
export class CountdownViewChildParentComponent implements AfterViewInit {
export class CountdownViewChildParentComponent {

@ViewChild(CountdownTimerComponent)
private timerComponent: CountdownTimerComponent;

seconds() { return 0; }

ngAfterViewInit() {
// Redefine `seconds()` to get from the `CountdownTimerComponent.seconds` ...
// but wait a tick first to avoid one-time devMode
// unidirectional-data-flow-violation error
setTimeout(() => this.seconds = () => this.timerComponent.seconds, 0);
}
seconds() { return this.timerComponent?.seconds ?? 0; }

start() { this.timerComponent.start(); }
stop() { this.timerComponent.stop(); }
Expand Down
@@ -1,19 +1,16 @@
// #docregion
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, OnDestroy } from '@angular/core';

@Component({
selector: 'app-countdown-timer',
template: '<p>{{message}}</p>'
})
export class CountdownTimerComponent implements OnInit, OnDestroy {
export class CountdownTimerComponent implements OnDestroy {

intervalId = 0;
message = '';
seconds = 11;

clearTimer() { clearInterval(this.intervalId); }

ngOnInit() { this.start(); }
ngOnDestroy() { this.clearTimer(); }

start() { this.countDown(); }
Expand All @@ -22,6 +19,8 @@ export class CountdownTimerComponent implements OnInit, OnDestroy {
this.message = `Holding at T-${this.seconds} seconds`;
}

private clearTimer() { clearInterval(this.intervalId); }

private countDown() {
this.clearTimer();
this.intervalId = window.setInterval(() => {
Expand Down

0 comments on commit 3104c3c

Please sign in to comment.