Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1. Import ActionsSubject
- import { ActionsSubject, select, Store } from '@ngrx/store';
- // ... missing decorator
- export class UsersPageComponent implements OnDestroy {
- // 2. Inject ActionsSubject
- constructor(
- private store: Store<AppState>,
- private dispatcher: ActionsSubject
- ) {
- this.listenForActions();
- }
- // 3. listen for actions
- listenForActions() {
- this.actionsSubscription = this.dispatcher
- .pipe(
- ofType(UsersActions.DELETE_SUCCESS),
- )
- .subscribe((shouldReset: boolean) => {
- // do something
- });
- }
- // 4. Don't forget to unsubscribe
- ngOnDestroy() {
- this.actionsSubscription.unsubscribe();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement