-
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
Only modify queryParams? #96
Comments
Hm, this is interesting. I think maybe the cleanest way to solve this is: Create a signal you call modalChanged, or something: modules/App/signals/modalChanged.js export default [
changeModal // An action which checks for the "input.modal" parameter and set the modal
] Now, what you is the same strategy as you handle authentication. You just create a factory for your signals to add this chain: module.addSignals({
homeClicked: withModal(homeClicked),
// like authentication is typically, same thing
homeClicked: authenticated(homeClicked)
}) The factory just composes the function withModal(chain) {
return modalChanged.concat(chain)
} You do not have to use a factory, you can also explicitly compose the [
getItems, {
success: [],
error: []
},
...modalChanged
] So here we trigger the modal at the end, but in an other signal you might want it to be first. Need the flexibility I think. The only missing piece now is how to update the url from function changeModal({input, state, services}) {
state.set('currentModal', input.modal);
services.router.addQuery({modal: input.modal});
} This might open up other possibilities. Adding queries manually could be beneficial in general. Okay, these are my initial thoughts :) |
Brilliant. Thanks for the insight. |
@Guria What do you think? About the |
Just one other thing to keep in mind: If developer wants to preserve other query params or completely replace them. A better method name might be
|
Hi, I took some of @christianalfoni's suggestions and created a POC repo here: https://github.com/awei01/cerebral-module-router-POC |
Some background is here: #92
Basic gist:
Currently, there's no way to know what the current signal or route is, so I cannot re-call the same signal and pass query params.
A workaround is to simply do
<a href="?modal=MyModal">Open Modal</a>
or something, but this circumvents the router altogether.The text was updated successfully, but these errors were encountered: