Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. this.store$
  2. .select(fromRoot.getUserState)
  3. .filter(user => user.id != null && user.logged)
  4. .takeUntil(this.componentDestroyed$)
  5. .do(user => this.store$.dispatch({type: 'ADD_SOURCE', payload: user.username}))
  6. .subscribe();
  7.  
  8. @Effect({ dispatch: true })
  9. addSource$: Observable<Action> = this.actions$
  10. .ofType('ADD_SOURCE')
  11. .switchMap(
  12. (action: Action) =>
  13. this.userService.addCard(action.payload.username, action.payload.token)
  14. .map((card: CardDTO) => {
  15. return <Action>{
  16. type: 'ADD_SOURCE_SUCCESS',
  17. payload: <ICard>{ ... }
  18. };
  19. })
  20. .catch(_ => {
  21. return Observable.of(<Action>{ type: 'ADD_SOURCE_FAILED', payload: { }});
  22. }));
  23.  
  24. private static saveSourceSuccess(sourcesRdx, type, payload) {
  25. return <ISourceRedux>{
  26. ids: [ ...sourcesRdx.ids, payload.id ],
  27. entities: Object.assign({}, sourcesRdx.entities, {[payload.id]: payload}),
  28. selectedIds: sourcesRdx.selectedIds,
  29. editingSource: null
  30. };
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement