-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Asynchronous data hook #7
Comments
router-view
There is going to be a |
Btw, thanks for these issues! It's really helpful to have feedback based on actual usage even before it's released :) |
👍 How do you plan to handle async data? In my case, I'm loading from an external data source. If I navigate to a page within the same component, causing a new set of |
What do you mean by "clear the data"? |
Currently a VM's |
There's an option called |
Although I haven't really put enough thought to the async data handling part yet - maybe there could be a more elegant solution. |
Alternatively - we can expose a |
|
By the way how exactly should I watch data: {
params: vm.$route.params
} and vm.$watch('params', callback, {deep: true}) does not work. |
The problem is that vm.$route.params was never updated when url changes from /entries/1/ to /entries/2/... |
@yyx990803 How would you go about to watch the $route.params anyway ? Thanks |
+1 Also interested in refreshing component data based on a change in param. |
Did you find a solution to this @rleger? I'm still trying to reload a component's data upon a param change. |
@benwalks the best I could come up with is to watch the route params.. not elegant but for lack of a better solution it works. ready() {
this.$watch('$route.params', this.handleChange , { deep: true })
} |
Well guys.. there has been a solution using The reason the component isn't reloaded when route change from whatever/1 to whatever/2 is that their route.canReuse is set to true by default, so they are reused and the lifecycle hooks were never fired again. A straightforward way would be to set canReuse to false, but using On 1 Oct 2015 I hadn't read though the docs carefully, so I posted the problems (which weren't) here. Later I read the docs and solved the problems, and totally forgot about this issue.... So I hope this helps @benwalks @rleger |
Yeah, thanks! I did actually figure that out in the end. Here's some sample code for future people.
|
I'm finding myself doing a deep watch of
router.params
in all of my components used by<router-view>
in order to reload the data loaded/initialized in my components'created
handler. Is there a better way about this? Should this automatically happen for navigation changes in the same router component?The text was updated successfully, but these errors were encountered: