I want to isolate bunch of @ngrx effects in my lazy loaded module so, that they can only be triggered if module related url is active. So if I understand correctly, effects are applied globally, and they are not depend on url, even if my module is lazy loaded, when this url is activated. So in every effect I write something like this
routeRelatedEffect$ = createEffect(() =>
this.actions$.pipe(
ofType(someAction),
withLatestFrom(this.store.pipe(select(selectRouterState))),
filter((rs) => rs.state.url.startsWith("/my-url"))
// ...
)
);
Here I check url. I wonder if there is another approach to do this? Maybe some sort of global filter? How is the right way to do this?
Effects can be added specifically to lazy loaded module.
If you want to have access to routes i suggest you to explore @ngrx/router-store https://ngrx.io/guide/router-store