Last active
January 4, 2017 18:03
-
-
Save kuy/a52356309b03e7f2fd74ed44ec2dd718 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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