markdalgleish/redial

Handling async route rendering at the client

autarc opened this issue · 2 comments

The example shown for the client doesn't regard the asynchronous behavior of fetching data and updating the view. Since the emitter/trigger don't hook into the underlying lifecycle of the component, the initial rendering will be executed and finished before the provideHook promises are resolved. At the server side this can be controlled through a wrapped response, while at the client it seems to be more difficult. In case of React Router for instance its probably necessary to define the onEnter transitions and invoke their callbacks as the result of a successful promise chain. Any thoughts for a general implementation ?

@autarc I have created new package, it's called reasync. It is in hard development but I believe this is one of the possible solutions how to handle pre and deferred fetching.

It's not clean, it's one of my first shots how i believe it can work, so PRs or at least issues are welcome. :)

@svrcekmichal Thanks, you actually pointed me in the right direction: using history.listenBefore instead of history.listen was a drop-in-replacement and solves the issue 👍

Submitted an improved example.