PromucFlow_constructor/app/client/src/sagas/WidgetSidebarSagas.tsx

23 lines
760 B
TypeScript
Raw Normal View History

2019-09-27 16:05:33 +00:00
import {
ReduxActionTypes,
ReduxActionErrorTypes,
2019-11-25 05:07:27 +00:00
} from "constants/ReduxActionConstants";
import WidgetSidebarApi, { WidgetSidebarResponse } from "api/WidgetSidebarApi";
import { successFetchingWidgetCards } from "actions/widgetSidebarActions";
import { call, put, takeLatest, all } from "redux-saga/effects";
2019-08-21 12:49:16 +00:00
2019-09-09 09:08:54 +00:00
export function* fetchWidgetCards() {
2019-08-21 12:49:16 +00:00
try {
2019-10-18 08:16:26 +00:00
const widgetCards: WidgetSidebarResponse = yield all([
call(WidgetSidebarApi.fetchWidgetCards),
]);
2019-09-09 09:08:54 +00:00
yield put(successFetchingWidgetCards(widgetCards.cards));
} catch (err) {
2019-09-27 16:05:33 +00:00
yield put({ type: ReduxActionErrorTypes.FETCH_WIDGET_CARDS_ERROR, err });
2019-08-21 12:49:16 +00:00
}
}
export function* fetchWidgetCardsSaga() {
yield takeLatest(ReduxActionTypes.FETCH_WIDGET_CARDS, fetchWidgetCards);
2019-09-09 09:08:54 +00:00
}