File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import {
2+ FETCH_PRODUCTS ,
3+ FETCH_PRODUCTS_SUCCESS ,
4+ FETCH_PRODUCTS_FAILED ,
5+ } from '../actions' ;
6+ import { put , call , takeLatest } from 'redux-saga/effects' ;
7+ import { getProducts } from '../services' ;
8+
9+ export function * fetchProducts ( ) {
10+ try {
11+ const receivedProducts = yield call ( getProducts ) ;
12+ yield put ( {
13+ type : FETCH_PRODUCTS_SUCCESS ,
14+ receivedProducts : receivedProducts . data ,
15+ } ) ;
16+ } catch ( error ) {
17+ yield put ( { type : FETCH_PRODUCTS_FAILED , error } ) ;
18+ }
19+ }
20+
21+ export function * watchFetchProducts ( ) {
22+ yield takeLatest ( FETCH_PRODUCTS , fetchProducts ) ;
23+ }
Original file line number Diff line number Diff line change 1+ import { all } from 'redux-saga/effects' ;
2+ import { watchFetchProducts } from './productsSagas' ;
3+
4+ export default function * rootSaga ( ) {
5+ yield all ( [ watchFetchProducts ( ) ] ) ;
6+ }
You can’t perform that action at this time.
0 commit comments