Reputation: 1020
I have a situation in my app where I need to share data between reducers.
State:
{
...
itemDetails,
settings
}
In the itemDetails
store, I need to update some data and to be able to do this I need some data from the settings
store.
(I’m also using facades.)
Is there a possibility to share data between reducers like redux-thunk
in react or something like this?
I also have other two options to do this:
settingsFacades
in itemDetailsFacades
and send those data directly in the action.But I’m curious if is there a more elegant method to share data between reducers.
Upvotes: 0
Views: 288
Reputation: 2376
Normally you can just access your store to get the data. For example in an effect it would look like this
constructor(private store$: Store<AppState>) {}
@Effect() specialEffect$ = this.actions$
.ofType(SOME_ACTION)
.withLatestFrom(this.store$)
.map(([action: Action, storeState: AppState]) => {
// Do something ... use selectors, dispatch action etc.
});
Upvotes: 1