I had two thunks, that I am trying to convert to a single saga. When the user logs into their dashboard, they make two API calls, one for projects and the other for notifications. In the thunks, following Flux standard actions invoking the errors for each was trivial, but I am unsure what the best approach is for doing this with sagas. This is what I have to start from:
export function* loadDashboard() {
try {
yield put({ type: types.notificationTypes.GET_NOTIFICATIONS_REQUEST });
const [projects, notifications] = yield all([
DashboardService.getProjects,
DashboardService.getNotifications
]);
yield put({
type: types.projectTypes.GET_PROJECTS_SUCCESS,
payload: projects
});
yield put({
type: types.notificationTypes.GET_NOTIFICATIONS_SUCCESS,
payload: notifications
});
} catch (error) {
//My guess is both of these will render the same error to their reducer,
//regardless of who the originator is
yield put({
type: types.projectTypes.GET_PROJECTS_FAILURE,
error: error.toString()
});
yield put({
type: types.notificationTypes.GET_NOTIFICATIONS_FAILURE,
error: error.toString()
});
}
}