Skip to content

Instantly share code, notes, and snippets.

@kuy
Last active January 4, 2017 18:03
Show Gist options
  • Save kuy/a52356309b03e7f2fd74ed44ec2dd718 to your computer and use it in GitHub Desktop.
Save kuy/a52356309b03e7f2fd74ed44ec2dd718 to your computer and use it in GitHub Desktop.
const routes = {
'/posts': {
'/:id': function* show({ params: { id } }) {
yield call(loadPost, id); // Wait for loading data
yield PostShow; // Component change
},
'/:id/edit': [function* edit({ params: { id } }) {
yield call(loadPost, id); // Wait for loading data
yield PostEdit;
}, function* dirtyCheck() {
if (yield select(isDirty)) {
yield false; // Prevent
}
}],
'/:id/update': function* update({ params: { id } }) {
yield take(SUCCESS_UPDATE_POST);
yield `/posts/${id}`; // Redirect
},
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment