-
Hi! I have a feeling that my whole setup is wonky, but I just want to get confirmation :) Is it possible to call an Consider this example: // state.someProperty == 'foo' before the invocation of outer()
public readonly outer = this.updater((state) => {
if (state.bla == true) {
this.inner() // call another updater function
}
this.myEffect()
return {
...state
}
});
public readonly inner = this.updater((state) => {
return {
...state,
someProperty: 'bar'
}
});
public myEffect = this.effect((_) =>
_.pipe(
withLatestFrom(this.state$),
switchMap(([_, state]) => {
return this.dataService.load(state.someProperty).pipe( // someProperty == 'foo' on the first invocation
tapResponse(
(response) => {
this.setResponse(response);
},
(e: string) => console.log(e)
),
catchError((_) => EMPTY)
);
})
)
); I defined How can I tackle this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After some thinking, I found a solution: The call order has to be inverted, instead of calling |
Beta Was this translation helpful? Give feedback.
After some thinking, I found a solution: The call order has to be inverted, instead of calling
updater
which in turn calls theeffect
, theeffect
should call theupdaters
after the asynchronous action. It worked out beautifully in my case.