stealjs / steal-tools

Build easy. Load fast.

Home Page:https://stealjs.com/docs/steal-tools.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

green3g opened this issue · comments

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.

Thanks for including a test case!

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?)

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

Thanks, I'll try again.

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.

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