Skip to content
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

Update model if query parameter is removed #125

Open
drarmstr opened this issue May 20, 2015 · 5 comments
Open

Update model if query parameter is removed #125

drarmstr opened this issue May 20, 2015 · 5 comments

Comments

@drarmstr
Copy link
Collaborator

If only a query search parameter changes (either in the main URL or in the URL hash) if would be nice to have a mode which avoided recreating the models and instead just updated the data binding.

For example, going from:

http://server.com/path/path?server=blarg#route?param=foo
to:
http://server.com/path/path?server=blarg#route?param=bar

@erikringsmuth
Copy link
Owner

You can do that with onUrlChange="updateModel"!
https://erikringsmuth.github.io/app-router/#/api#onurlchange

<app-router>
  <app-route path="/user/:userId/**" element="user-page" onUrlChange="updateModel"></app-route>
</app-router>

@drarmstr
Copy link
Collaborator Author

Ah, thank you! I missed the link to the documentation from the GitHub page and was just working off readme.md

@drarmstr
Copy link
Collaborator Author

Actually, I am seeing an issue where if the URL is updated to remove a hash path query parameter then the corresponding data binding is not updated by setting the property to undefined. Instead, it retains its previous value.

e.g., going from:
http://server.com/path/path?server=blarg#route?param=foo
to:
http://server.com/path/path?server=blarg#route

@erikringsmuth erikringsmuth reopened this May 22, 2015
@erikringsmuth
Copy link
Owner

I see where the problem is but I'm not sure how to fix this one. Updating the model happens here https://github.com/erikringsmuth/app-router/blob/master/src/app-router.js#L266. The problem is setObjectProperties() only sets properties in the new model and doesn't know how to delete/undefine properties from the old model. The tricky part is the existing model is all mixed in with the custom element's properties.

@drarmstr
Copy link
Collaborator Author

I guess keep a map of current known parameters and if any disappear then delete them?

On May 25, 2015, at 19:11, Erik Ringsmuth [email protected] wrote:

I see where the problem is but I'm not sure how to fix this one. Updating the model happens here https://github.com/erikringsmuth/app-router/blob/master/src/app-router.js#L266. The problem is setObjectProperties() only sets properties in the new model and doesn't know how to delete/undefine properties from the old model. The tricky part is the existing model is all mixed in with the custom element's properties.


Reply to this email directly or view it on GitHub.

@drarmstr drarmstr changed the title Avoid recreating model if only query search parameter changes Update model if query parameter is removed Dec 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants