How can I dispatch an action of a different type in Redux Observables, instead of ApplicantAction
, because I need the data passed in the response
?
const updateApplicantEpic: Epic<ApplicantAction, ApplicantAction, State> = action$ =>
action$.pipe(
filter(isOfType(EApplicantAction.UpdateApplicant)),
mergeMap(action =>
from(
createAxiosInstance().put(`/applicant/edit/${action.applicantId}`, action.applicant),
).pipe(
map(({ status }) => updatedApplicant(status, action.applicant)),
startWith(updatingApplicant()),
catchError(({ response }) => of(updatingApplicantFailed(response.status))),
),
),
);
I want to trigger the setNotification()
action with this specific data:
{
id: action.notificationId,
status: response.status
title: response.data.title,
message: response.data.messages?.join('\n'),
open: false
}
This is how my second action would look like:
const setNotificationEpic: Epic<NotificationAction, NotificationAction, State> = action$ =>
action$.pipe(
filter(isOfType(ENotificationAction.SetNotification)),
map(action => setNotificationSuccess(action.notification)),
);