client/src/sagas/groupSaga.js
changeset 100 6fd752d98933
child 101 e165aa89ac82
equal deleted inserted replaced
99:18fa4a1fa9e9 100:6fd752d98933
       
     1 import { put, take, all } from 'redux-saga/effects'
       
     2 import * as types from '../constants/actionTypes';
       
     3 
       
     4 function* watchCreateGroup(context) {
       
     5   while (true) {
       
     6     const { group } = yield take(types.GROUP_CREATE_ASYNC);
       
     7     const client = context.client;
       
     8     try {
       
     9       const response = yield client.post('/api/auth/group/', group);
       
    10       yield put({ type: types.GROUP_CREATE_SUCCESS, group: response });
       
    11     } catch (e) {
       
    12       yield put({ type: types.GROUP_CREATE_ERROR, error: e });
       
    13     }
       
    14   }
       
    15 }
       
    16 
       
    17 export default function* rootSaga(context) {
       
    18   yield all([
       
    19     watchCreateGroup(context),
       
    20   ])
       
    21 }