import { Platform } from '@angular/cdk/platform';
import { AsyncPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { interval, startWith } from 'rxjs';
import { LetDirective } from '@yelon/abc/let';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
@Component({
selector: 'components-let-async',
template: `
@if (timer$ !== null) {
<ng-container *let="timer$ | async as time">
<p>Timer value: {{ time }}</p>
<p>Timer value: {{ time }}</p>
<p>Timer value: {{ time }}</p>
</ng-container>
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [LetDirective, AsyncPipe]
})
export class ComponentsLetAsyncComponent {
timer$: NzSafeAny | null = null;
constructor(platform: Platform) {
if (!platform.isBrowser) return;
this.timer$ = interval(1000).pipe(startWith(0));
}
}