Last active
November 20, 2019 14:43
-
-
Save tzachbon/f514e25dcf02c2bf95e2e4bf339a0913 to your computer and use it in GitHub Desktop.
SetChecker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; | |
| import { BehaviorSubject } from 'rxjs'; | |
| import { ReRenderOnChange, SetChecker, WithObservable } from '@intelligo.ai/bonfire'; | |
| @ReRenderOnChange() | |
| @Component({ | |
| selector: 'app-test', | |
| styles: [ | |
| ` | |
| .container { | |
| margin: 1rem; | |
| color: white; | |
| } | |
| ` | |
| ], | |
| changeDetection: ChangeDetectionStrategy.OnPush, | |
| template: ` | |
| <div class="container"> | |
| <button (click)="initRandomNumber()"><h1>Click Here To Start!</h1></button> | |
| <h3 *ngFor="let num of randomNumbers"> | |
| {{num.newNumber}} | |
| </h3> | |
| </div> | |
| `, | |
| }) | |
| export class TestComponent implements OnInit { | |
| @SetChecker() randomNumbers = []; | |
| constructor( | |
| private cd: ChangeDetectorRef | |
| ) { } | |
| ngOnInit() { | |
| } | |
| initRandomNumber() { | |
| setTimeout(() => { | |
| this.randomNumbers = [...new Array(5)].map(e => ({ newNumber: 0 })); | |
| setTimeout(() => { | |
| this.randomNumbers[0].newNumber = 40; | |
| }, 2000); | |
| }, 2200); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment