Created
October 19, 2016 18:10
-
-
Save mikehaas763/f2fd2769aca9b6d51e45ff8f475dad9d to your computer and use it in GitHub Desktop.
This file contains 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
//In an onPush component a method called by constructor this code exists: | |
this.store.select('searchResultsGrid') | |
.map(results => results.visibleResultsCount) | |
.distinctUntilChanged() | |
.skip(1) | |
.subscribe(count => { | |
console.log('new count is ', count); | |
this.resultsCount = count; | |
this._cdRef.markForCheck(); | |
}) | |
//This is the binding on the components template: | |
//<span *ngIf="resultsCount !== 1" class="md-headline">{{resultsCount}} Results</span> | |
//<span *ngIf="resultsCount === 1" class="md-headline">{{resultsCount}} Result</span> | |
//the code inside of the subscription fires, but the view does not reflect the change until the next event triggers. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment