Skip to content

Commit 79719c5

Browse files
committed
Fixed issue: notification not dispatched on request error. (fixes #52)
1 parent 0ad9f68 commit 79719c5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/epics.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ofType } from 'redux-observable';
44
import { Observable, of, pipe } from 'rxjs';
55
import objectAssignDeep from 'object-assign-deep';
66
import { concatMap, mergeMap, map, takeUntil, filter, catchError } from 'rxjs/operators';
7+
import { throwError } from 'rxjs';
78
import { createNotification, NOTIFICATION_TYPE_SUCCESS, NOTIFICATION_TYPE_ERROR } from 'react-redux-notify';
89
import {
910
receiveData,
@@ -58,9 +59,9 @@ export const fetchDataEpic = ( action$, state$, { api }) => action$.pipe(
5859
return { response, data };
5960
}),
6061
map((payload) => receiveData({ name, payload })),
61-
catchError((error) => of(
62+
catchError((error) => of(
63+
createNotification({ type: NOTIFICATION_TYPE_ERROR, message: error.message }),
6264
cancelRequest({ name }),
63-
createNotification({ type: NOTIFICATION_TYPE_ERROR, message: error.message })
6465
)),
6566
takeUntil(action$.pipe(
6667
ofType(REQUEST_DATA_CANCEL),
@@ -91,8 +92,8 @@ export const deleteDataEpic = ( action$, state$, { api }) => action$.pipe(
9192
);
9293
}),
9394
catchError((error) => of(
95+
createNotification({ type: NOTIFICATION_TYPE_ERROR, message: error.message }),
9496
cancelRequest({ name }),
95-
createNotification({ type: NOTIFICATION_TYPE_ERROR, message: error.message })
9697
))
9798
);
9899
})

0 commit comments

Comments
 (0)