Skip to content

Instantly share code, notes, and snippets.

@adamgen
Created May 6, 2020 16:37
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 adamgen/4767857f71e140f3d60c8c58a5aae307 to your computer and use it in GitHub Desktop.
Save adamgen/4767857f71e140f3d60c8c58a5aae307 to your computer and use it in GitHub Desktop.
NGRX | Use effects and router-store to isolate route related side πŸ§™πŸΌβ€β™‚οΈ effects - effects injectable
setCurrentCourse$ = createEffect(() => this.actions$.pipe(
ofType(ROUTER_NAVIGATED), // get router navigated ngrx actions
mergeMap(() => this.store.pipe(
select(selectRouteParam(β€˜id’))) // get the id from the router store
),
map((id: string) => setIds({ id })), // dispatch a new action to set the selected id
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment