DEV Community

loading...

Discussion on: NGRX | Use effects and router-store to isolate route related side 🧙🏼‍♂️ effects

Collapse
timdeschryver profile image
Tim Deschryver

Woo-hoo effects!
This can be made a little bit easier imho by just using the id selector as the source of the effect

 setCurrentCourse$ = createEffect(() => this.store.pipe(select(selectRouteParam('id') as any)))
  .pipe(
     map((id: string) => setIds({ id })), // dispatch a new action to set the selected id
   ), { dispatch: true });
Collapse
adamgenshaft profile image
Adam Genshaft Author

Effects are magical, are they :)

Thanks, I agree with you so I updated the example 🚀