forge42dev / remix-client-cache

Utility library to cache your client data in Remix.run
MIT License
157 stars 2 forks source link

Idea: refetching status #3

Open FKSI opened 7 months ago

FKSI commented 7 months ago

In swr mode expose a "fetching state" to let the app display a skeleton for example.

AlemTuzlak commented 7 months ago

hmm i'm not sure if this would be justified as this would be identical behavior to not using the package and just passing the server data as a promise / using defer without clientLoader, could you give me an example of the use-case?

FKSI commented 7 months ago

What if you are handling like a list of items (books?) the first time you hit the page serverLoader is going to fetch the data.

Let's add in the backend 10+ items

The second time you are going to the app the clientLoader is serving the data from storage and behind the scenes the a fetch is happening (swr mode). If the fetch is slow (or your network is bad) then the it takes some time to finish and finally the app will display the new 10+ items but the UI effect will be a kind of "appearing in a blink".

If the lib exposes a "isBackgroundFetchingStatus" then in the UI you could display a banner (or whatever) warning the user that some new data might appear in the coming seconds.

Amazing work btw!

AlemTuzlak commented 7 months ago

@FKSI I see, okay, I think I've figured out how to add it