Resource with async cache
Whats the pattern for using resources with caching that may be async?
What I mean by that is that my
I want to display the cached value while I fetch the actual, (the cached value is considered stale) so I cannot simply add it to the
I thought that using
Here are my two attempts:
one with transitions:
https://playground.solidjs.com/anonymous/6b0c7b0f-d2ec-458a-8536-883da3ae55a6
and one with additional signals:
https://playground.solidjs.com/anonymous/ef897a99-c8da-4a17-84a4-68772a0cb934
Although they do kinda work, they feel incorrect.
They both have the same problem that the "user" cannot easily control whether he wants to show the cached value or not. (As they could with
It seems that maybe calling
What I mean by that is that my
cache_get function returns a promise so I cannot set it to the initialValue option of resources.I want to display the cached value while I fetch the actual, (the cached value is considered stale) so I cannot simply add it to the
fetcher.I thought that using
mutate with res.latest would give the desired behaviour, where Suspense is only triggered when initially, and not-triggered when cached value is set.Here are my two attempts:
one with transitions:
https://playground.solidjs.com/anonymous/6b0c7b0f-d2ec-458a-8536-883da3ae55a6
and one with additional signals:
https://playground.solidjs.com/anonymous/ef897a99-c8da-4a17-84a4-68772a0cb934
Although they do kinda work, they feel incorrect.
They both have the same problem that the "user" cannot easily control whether he wants to show the cached value or not. (As they could with
res.latest and initialValue)It seems that maybe calling
mutate should set resuorce into "refreshing" state.