Last active
December 30, 2016 08:07
-
-
Save kuy/6ae391625b24a9f6b08dcf8bd9f066a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EditPage extends React.Component { | |
handleUpdate() { | |
const form = ...; | |
this.props.dispatch(requestUpdate(form)); | |
} | |
// ... | |
render() { | |
return <div> | |
// ... | |
<button onClick={this.handleUpdate.bind(this)}>Update</button> | |
// ... | |
</div>; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* handleUpdate() { | |
while (true) { | |
const form = yield take(REQUEST_UPDATE); | |
yield put(loading(true)); | |
const data = yield call(api, form); | |
yield put(loading(false)); | |
yield put(successUpdate(data)); | |
yield put(change(IndexPage)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment