Last active
March 14, 2019 02:23
-
-
Save alex-okrushko/69032e799cdeb5d90bdc4bd0472a8d68 to your computer and use it in GitHub Desktop.
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
| @Component({ | |
| selector: 'app-movies-page', | |
| template: ` | |
| <h1>Movies Page</h1> | |
| <div *ngIf="error$ | async as error"> | |
| {{ error }} | |
| </div> | |
| <button (click)="reload()">Refresh List</button> | |
| ` | |
| }) | |
| export class MoviesPageComponent { | |
| error$: BehaviorSubject<string>; | |
| constructor( | |
| private store: Store<fromRoot.State>, | |
| actions$: Actions, | |
| ) { | |
| this.error$ = new BehaviorSubject<string>(''); | |
| actions$.pipe( | |
| ofType('[Movies/API] Load Movies Failure'), | |
| ).subscribe(this.error$); | |
| this.store.dispatch({ type: '[Movies Page] Load Movies' }); | |
| } | |
| reload() { | |
| this.error.next(''); | |
| this.store.dispatch({ type: '[Movies Page] Load Movies' }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment