Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Allow asset hydration #8

Open
lxsmnsyc opened this issue Nov 11, 2020 · 2 comments
Open

Allow asset hydration #8

lxsmnsyc opened this issue Nov 11, 2020 · 2 comments

Comments

@lxsmnsyc
Copy link

lxsmnsyc commented Nov 11, 2020

Some frameworks like Next performs data prefetching in the server-side, providing the initial data for the whole app. Libraries like swr and react-query takes advantage of this by using the prefetched data as the initial cache data and performs the fetch process/cache invalidation only on client-side.

Asset hydration helps because React SSR cannot handle nor does not support Suspense (CM, however, supports this) and since the asset is guaranteed to have an initial data, the component does not have to suspend during SSR and the potentially suspending component can safely present its success UI.

I think something like asset.hydrate(args, data) or useAsset(asset, args, initialData) is a good API. Thoughts?

@drcmda
Copy link
Member

drcmda commented Nov 11, 2020

seems useful, would you want to open a pr for this?

@lxsmnsyc
Copy link
Author

lxsmnsyc commented Nov 13, 2020

@drcmda I'm willing to, although I have yet to address some minor issues in the code (e.g. type unsoundness). I'll probably address those on a separate issue

edit:
Just saw @dai-shi 's commits, looks like the issues are fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants