Note: run npm install or yarn after merge this branch
As you see in lib/redux/form/saga.js, each submitting will take 1 sec.
export default function * formSaga () {
while (true) {
// Wait untill SUBMIT_FORM dispatch
yield take(actionTypes.SUBMIT_FORM)
// Grab form state in redux store
const form = yield select(state => state.form)
// Execute async function, which return promise
// delay is a helper function of redux saga which just wait given amount of time and resolve true
// We probably need this when we are going to implement http request for submitting
yield call(delay, 1000)
// dispatch addPost action
yield put(postActions.addPost({
post: {
title: form.title,
content: form.content
}
}))
// dispatch resetForm action
// Actually, dispatching multiple actions considers harmful.
// At the first, this usage is fine. But, if we have a performance issue, we have to unify these action into a huge single action.
yield put(actions.resetForm())
}
}
Note: run
npm install
oryarn
after merge this branchAs you see in
lib/redux/form/saga.js
, each submitting will take 1 sec.