Skip to content

Instantly share code, notes, and snippets.

@alex-okrushko
Last active March 14, 2019 02:23
Show Gist options
  • Select an option

  • Save alex-okrushko/69032e799cdeb5d90bdc4bd0472a8d68 to your computer and use it in GitHub Desktop.

Select an option

Save alex-okrushko/69032e799cdeb5d90bdc4bd0472a8d68 to your computer and use it in GitHub Desktop.
@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