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

live-reload with donejs breaks can-route bindings to update route #930

Closed
green3g opened this issue Jan 22, 2018 · 6 comments
Closed

live-reload with donejs breaks can-route bindings to update route #930

green3g opened this issue Jan 22, 2018 · 6 comments
Assignees

Comments

@green3g
Copy link

green3g commented Jan 22, 2018

If I have a component that binds to route.data.propName from the app view model in donejs, live-reload will break the binding somehow and the route no longer gets updated.

https://github.com/roemhildtg/donejs-can-route-bug

Parent Component ViewModel:

  routeData: {
    get(){ return route.data; }
  }

Template:

<my-component id:bind="routeData.a" />

In my-component viewmodel:
this.id = newValue;

This will update the route.data.a property to newVal but the route is no longer updated.

@matthewp
Copy link
Member

Thanks for including a test case!

@matthewp matthewp self-assigned this Feb 9, 2018
@matthewp
Copy link
Member

matthewp commented Feb 9, 2018

Hey, so I've gotten around to this. I'm a little confused. First, there is no <my-component id:bind="routeData.a" /> that I can find. There's <my-component /> in the index.stache. Secondly, you said to do this.id = newValue;, I assume this is meant to trigger a live reload, but where should this code be added (like, is there a function in the viewmodel that needs to be created?)

@green3g
Copy link
Author

green3g commented Feb 9, 2018

I didn't do a great job of explaining my demo. After more testing, I think live-reload just breaks routing in general. Whenever a file is live-reloaded in donejs, routing seems to stop working.

But here is my demo explanation anyways. Binding in my demo actually looks like this:

Route.data.a
-> my-component.routeData.a
-> child-component.count

First, there is no <my-component id:bind="routeData.a" /> that I can find.

So in my demo, the line is actually child-component that gets the routeData from my-component:
https://github.com/roemhildtg/donejs-can-route-bug/blob/master/src/my-component/my-component.stache#L4

this.id = newValue;, I assume this is meant to trigger a live reload, but where should this code be added (like, is there a function in the viewmodel that needs to be created?)

I didn't mean that this shouldn't trigger a live reload, it should update the route. But After a live-reload has occurred (IE you modify a file, the file gets reloaded in the browser, routing no longer works. In my demo, the piece that updates the route is here:
https://github.com/roemhildtg/donejs-can-route-bug/blob/master/src/child-component/child-component.js#L14

@matthewp
Copy link
Member

matthewp commented Feb 9, 2018

Thanks, I'll try again.

@matthewp
Copy link
Member

matthewp commented Feb 9, 2018

I think this is a bug in can-route. When you change route.data (as we do in live-reload), the url is still bound to the old viewmodel.

@matthewp
Copy link
Member

matthewp commented Feb 9, 2018

The underlying issue is here: canjs/can-route#153 . Will track from there.

@matthewp matthewp closed this as completed Feb 9, 2018
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