Skip to content

Instantly share code, notes, and snippets.

@Mulperi
Last active November 9, 2018 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mulperi/c83864d29e60b2bd5eee887d097b5fa1 to your computer and use it in GitHub Desktop.
Save Mulperi/c83864d29e60b2bd5eee887d097b5fa1 to your computer and use it in GitHub Desktop.
NGRX Effect and withLatestFrom example
@Effect()
selectItem$ = this.actions$.pipe(
ofType(itemAction.ITEM_SELECT),
concatMap(() =>
this.store.select(fromItems.getItemsSelected)
),
withLatestFrom(
this.store.select(fromUi.getItemsSideviewVisible)
),
filter(
// Do not dispatch new action if sideview is already visible
([selected, sideViewVisible]) =>
!sideViewVisible && selected.length > 0
),
map(() => new uiAction.ShowItemsSideview())
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment