client/src/sagas/groupSaga.js
changeset 100 6fd752d98933
child 101 e165aa89ac82
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/src/sagas/groupSaga.js	Tue Jun 27 18:12:10 2017 +0200
@@ -0,0 +1,21 @@
+import { put, take, all } from 'redux-saga/effects'
+import * as types from '../constants/actionTypes';
+
+function* watchCreateGroup(context) {
+  while (true) {
+    const { group } = yield take(types.GROUP_CREATE_ASYNC);
+    const client = context.client;
+    try {
+      const response = yield client.post('/api/auth/group/', group);
+      yield put({ type: types.GROUP_CREATE_SUCCESS, group: response });
+    } catch (e) {
+      yield put({ type: types.GROUP_CREATE_ERROR, error: e });
+    }
+  }
+}
+
+export default function* rootSaga(context) {
+  yield all([
+    watchCreateGroup(context),
+  ])
+}