Closed mdings closed 3 years ago
Init can be fired by multiple different events - When a link enters the view port if eagerLoad is enabled, else it's when a mouse hovers on a link, when you click on a link or last resort, when the view is loaded.
This strategy is borrowed from gatsbyjs, the idea is to make sure data for the next pages is always ready for a fast user experience. Overfetching is less of an issue with gatsby or hyperstatic because the data that is fetched is static JSON files on the same domain. (versus expensive API calls on a live backend).
If you want to trigger an action when pages changes, you use the onRouteChanged
subscription
Thanks, that explains!
I can't find a consistent pattern when the Init method is being fired. Consider the following example on a "page" component:
and the following routes:
Whenever I hit the homepage I can see the console message for Contact and Product coming in, but not for Brand.. This makes me wonder whether Init function should at all trigger when a route is not matched? Should it or not? Or only when there is an exact match on the route?
If the latter in the case there is probably a bug with the route matching mechanism