1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

flow redux

This commit is contained in:
muerwre 2019-08-24 17:58:39 +07:00
parent 9691504af6
commit 95443635b4
11 changed files with 118 additions and 10 deletions

View file

@ -1,11 +1,20 @@
import { takeLatest, call } from 'redux-saga/effects';
import { takeLatest, call, put } from 'redux-saga/effects';
import { NODE_ACTIONS } from './constants';
import { nodeSave } from './actions';
import { nodeSave, nodeSetSaveErrors } from './actions';
import { postNode } from './api';
import { reqWrapper } from '../auth/sagas';
function* onNodeSave({ node }: ReturnType<typeof nodeSave>) {
const { data, errors } = yield call(reqWrapper, postNode, { node });
yield put(nodeSetSaveErrors({}));
const {
data,
data: { errors },
} = yield call(reqWrapper, postNode, { node });
if (errors && Object.values(errors).length > 0) {
return yield put(nodeSetSaveErrors(errors));
}
console.log({ data, errors });
}