Ngrx effects not working when in a preloaded module
Asked Answered
A

0

6

I have two modules, let's call them EagerModule and PrealodedModule. Both of them have their own feature reducers and effects.

EagerModule is loaded eagerly in the app, meaning its in the list of AppModule's imports.

@NgModule({
    imports: [
        // .. other modules
        EagerModule
    ]

PreloadedModule, on the other hand, is loaded lazily, but since I am using preloadingStrategy: PreloadAllModules, we can say that it's basically preloaded (meaning, it's being loaded just after all eager modules are loaded).

I am trying to dispatch an action from PrealoadedModule in a EagerModule's component. However, it seems like the effects are not being initialized as my action doesn't perform the http request that it is supposed to. I tried hacking this by only dispatching this action after I have a value in PreloadedModule's state selector, however, this didn't work either.

The only way I can get this working is if I load PreloadedModule eagerly, but that is not what I want to achieve.

So, how can I make effects from a preloaded module work in another module?

Aurify answered 15/10, 2019 at 15:59 Comment(4)
How are you including the effects module?Leone
In AppModule it is EffectsModule.forRoot(effects), and in all feature module it goes like EffectsModule.forFeature(effects)Aurify
have you found any solution to this? I'm in a similar situation but the only difference is i'm not using preloading strategy. I have a effect that listen to an action on a eagerloaded module but when that action is dispatched, the effect doesn't runProvidential
Having same issue, have you found solution to this?Lazarus

© 2022 - 2024 — McMap. All rights reserved.