Skip to content

Instantly share code, notes, and snippets.

@mfp22
Last active March 23, 2021 07:54
Show Gist options
  • Select an option

  • Save mfp22/b633794bc6b5d636caa0ffa817b60e39 to your computer and use it in GitHub Desktop.

Select an option

Save mfp22/b633794bc6b5d636caa0ffa817b60e39 to your computer and use it in GitHub Desktop.
@Effect getUsers$ = this.actions$.pipe(
ofType('GET_USERS', 'CANCEL_GET_USERS'),
withLatestFrom(this.userSelectors.needUsers$),
filter(([action, needUsers]) => needUsers),
map(([action, needUsers]) => action),
switchMap(action => action.type === 'CANCEL_GET_USERS' ?
Observable.of() :
this.getUsers().pipe(
map(users => ({type: 'RECEIVE_USERS', users})),
),
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment