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

1102: $route returns consistent value across all Vue instances #1108

Merged
merged 2 commits into from
Jan 23, 2017
Merged

1102: $route returns consistent value across all Vue instances #1108

merged 2 commits into from
Jan 23, 2017

Conversation

jhartman86
Copy link
Contributor

  • Allow injecting router to discrete Vue instances and ensure the $route (getter) returns consisten value

- Allow injecting router to discrete Vue instances and ensure the $route (getter) returns consisten value
@jhartman86
Copy link
Contributor Author

jhartman86 commented Jan 20, 2017

Maintainers - not expecting for this PR to get accepted right away as I'm guessing it violates the coding standards somewhere. If feedback can be provided on what needs to be fixed for it to be accepted it'd be great.

Note - the simplest fix was to keep track of all the app instances and just set the private _route property on all of them. That effectively accomplishes keeping the $route value in sync across all instances.

@@ -89,7 +92,11 @@ export default class VueRouter {
}

history.listen(route => {
this.app._route = route
this.apps.forEach((app) => {
if (app) {
Copy link
Member

@posva posva Jan 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A check shouldn't be necessary, should it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats what I thought as well, but the syntax check wouldn't let it pass. Don't remember exactly, but it was along the lines of "Cannot set property on a possibly null value".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants