-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is there a way to prevent routes from triggering? #93
Comments
I can't see a good way to prevent such case. Link component triggers signals, not routes. You can add an action to your signal which will check that navigation currently unwanted. But from UX point of view I would recommend just have smart form state restore if user returns back after unwanted navigation. |
I would suggest the same approach as "authentication" again. module.addSignals({
homeClicked: preventUnfinished(homeClicked)
}) This factory has the logic for ensuring that something started is also finished: function preventUnfinished(chain) {
return [
isNotFinished, {
formA: [notifyFormAError],
formB: [notifyFormBError],
otherwise: chain
}
];
} This will actually also notify when the url is manually changed... which is not the case typically in these scenarios. The debugger will also show very clearly what is happening on these scenarios. Does that make sense? |
This makes sense. But, now it seems like any routeable signal will require these factories to work properly. Just throwing out another idea: What if the |
@awei01 That is an interesting suggestion! Though I believe you would still need to use factories on all the routed signals, because I suppose you want to give an error if the user tries to route and it is prevented? Hm hm :) |
Good point... I'll play around with your suggestion. If I find anything useful, I'll post it here. |
Took some of @christianalfoni's suggestions and created a POC here: https://github.com/awei01/cerebral-module-router-POC |
Hi, I'm wondering if there's a way to prevent routes from triggering or addressbar url change.
Use case: Someone is filling out a form and doesn't save. But then they click on a different link or change address in address bar. Is there a best-practice way to handle this?
The text was updated successfully, but these errors were encountered: