Last active
December 28, 2019 17:03
-
-
Save ThomasBurleson/d245aba022646bc28223fbb46cdd5e76 to your computer and use it in GitHub Desktop.
Compressing View Logic with Facades
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
/** | |
* | |
* Snippet from blog article: https://auth0.com/blog/ngrx-facades-pros-and-cons/ | |
* | |
*/ | |
@Component({ | |
selector: 'abl-books-page', | |
changeDetection: ChangeDetectionStrategy.OnPush, | |
template: ` | |
<mat-card> | |
<mat-card-title>My Collection</mat-card-title> | |
<mat-card-actions> | |
<button mat-button raised color="accent" (click)="logout()">Logout</button> | |
</mat-card-actions> | |
</mat-card> | |
<abl-book-preview-list [books]="books$ | async"></abl-book-preview-list> | |
}) | |
export class BooksPageComponent implements OnInit { | |
books$: Observable<Book[]>; | |
constructor(private booksFacade: BooksFacadeService) { | |
this.books$ = booksFacade.allBooks$; | |
} | |
ngOnInit() { | |
this.booksFacade.dispatch(new BooksPageActions.Load()); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would've done
and
Even simpler! Thanks for bringing us this awesome pattern, Thomas!