#Dispatch action conditionaly based on previous action response
26 messages ยท Page 1 of 1 (latest)
you are missing the default return
and the return for the else
you need to validate all use cases
but I agree, the error is not simple to understand
I even tried to add empty action for default case, but seems not good enough ๐
you are missing the else case
I have covered that case also by adding
else {
return PlanningActions.emptyAction();
}
but still the same issue
public onUpdateOptimizationResult$ = createEffect(() =>
this.actions$.pipe(
ofType(PlanningActions.updateOptimizationResult),
switchMap(({ message }) => {
if (message.status && message.startDate && message.expectedEndDate) {
switch (message.status) {
case RopOptimizationStatusEnum.OPTIMIZATION_CANCELLED:
return PlanningActions.cancelOptimization();
case RopOptimizationStatusEnum.OPTIMIZATION_FINISHED:
return PlanningActions.finishedOptimization();
default:
return PlanningActions.emptyAction();
}
} else {
return PlanningActions.emptyAction();
}
})
)
);
can you show me your action definition?
and emptyAction?
const emptyAction = createAction('[Planning Page] Empty Action');
and the error message is still the same?
Yeap, on hover i see the same error message
Just to show on what type of action I am listening, it supposed to return message object
ok got it
you are using switchmap
but you are not doing any async operation inside your effect
switchmap let your flat map obs<obs<any>>
so here a simple map is enough
that more about rxjs but yes sometimes you are so focus on something. you forgot to look elsewhere
you should mark your thread as valid with the โ on your first message so that others will see it
Yeap, I just resolved it ๐ thanks man, I am happy to be part of this awesome community