Advertisement
fabiobiondi

Untitled

Jun 19th, 2019
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1.  
  2. // 1. Import ActionsSubject
  3. import { ActionsSubject, select, Store } from '@ngrx/store';
  4.  
  5. // ... missing decorator
  6. export class UsersPageComponent implements OnDestroy {
  7.  
  8. // 2. Inject ActionsSubject
  9. constructor(
  10. private store: Store<AppState>,
  11. private dispatcher: ActionsSubject
  12. ) {
  13. this.listenForActions();
  14. }
  15.  
  16. // 3. listen for actions
  17. listenForActions() {
  18. this.actionsSubscription = this.dispatcher
  19. .pipe(
  20. ofType(UsersActions.DELETE_SUCCESS),
  21. )
  22. .subscribe((shouldReset: boolean) => {
  23. // do something
  24. });
  25. }
  26.  
  27. // 4. Don't forget to unsubscribe
  28. ngOnDestroy() {
  29. this.actionsSubscription.unsubscribe();
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement