WithRedux Unable to execute multiple effects for action
Chudroy opened this issue · 2 comments
Using WithRedux, I have three effects. The first effect dispatches an action. The other two effects are listening for this action. Only the third effect fires, the second one doesn't. If i remove the third effect, the second one fires. It seems only one effect can listen for an action at a time.
Proposed fix: make it like original ngrx store, multiple effects can listen for an action.
loadInstallationDetail$: create(actions.loadInstallationDetail).pipe(
switchMap(({ installationId }) => {
return installationsService.getInstallation(installationId).pipe(
tapResponse(
(installation) => {
actions.loadInstallationDetailSuccess({
installation,
});
},
(error: HttpErrorResponse) => {
httpErrorSnackbarService.showHttpErrorSnackbar(error);
},
),
);
}),
),
loadInstallationDetailSuccess$: create(
actions.loadInstallationDetailSuccess,
).pipe(
tap(({ installation }) => {
const title = installation?.name;
const id = installation?.id.toString();
if (id && title) {
globalStore.dispatch(
LayoutStateActions.setLayoutState({
id,
entityType: 'installation',
title,
}),
);
}
}),
),
loadInstallationCampaigns$: create(
actions.loadInstallationDetailSuccess,
).pipe(
switchMap(({ installation }) => {
return installationsService
.getInstallationCampaigns(installation?.id?.toString())
.pipe(
tapResponse(
(campaigns) => {
return actions.loadInstallationCampaignsSuccess({
campaigns: campaigns || [],
});
},
(error: HttpErrorResponse) => {
httpErrorSnackbarService.showHttpErrorSnackbar(error);
},
),
);
}),
),
the second effect, loadInstallationDetailSuccess$
doesn't fire. the effect loadInstallationCampaigns$
does however. This seems to me that the create
function is overwriting the subscription to the action `actions.loadInstallationDetailSuccess of the second effect with the third effect's subscription to the same action.
Thanks for the info. Fix will follow
Has been fixed in version 0.3.0