Closed timkendall closed 6 years ago
Would be maybe cool to make the loading state available to the Link
component at least? Then consumers could easily implement links that have loading indicators. This would in fact be useful also for routes that have been code split (if we ever implement that).
I implemented this feature in a simpler way, just including async / await
in the goTo
function. Seems working so far. Until https://github.com/kitze/mobx-router/pull/56 get merged, feel free to use https://www.npmjs.com/package/mobx-router-3
Merged now
As documented in the Readme, allowing async
beforeEnter
andbeforeExit
hooks would be a nice feature to support.I started implementing it here -> https://github.com/timkendall/mobx-router/tree/feat/async-hooks
While the basic implementation is done (needs test coverage), I did notice one edge case we will need to handle - if a route entry is scheduled, there needs to be a way to cancel it (i.e before the async hooks resolve).
Another issue to think about - should this lib keep track of if a route is in the "loading" state (i.e if an async hook is resolving)? Or should we letter consumers do that?
@kitze thoughts?