zulu
Preferred way of handling `429 Too Many Requests` with `createResource`?
yeah, I guess hiding the problem might be the 1st issue
( fallback to cache on error)
might be acceptable in your use case
2nd issue, is that quote in LocalStorage might be empty
there is no guarantee that this request was called before.
4 replies
createEffect vs createEffect + on
key points:
1
when you set an object with another object using the store setter. there is a shallow merge
if you create an effect on
store.a
setting the store.a
like we did above
will not trigger. ( because the setter preforms a shallow merge which does not replace the value of store.a
only a value change in the a
key, will trigger a tracking of store.a
2
spreading allow the effect to track not just existing keys, but also new keys that may be added in the future.
for example
if we set a new value in store.a
now
we will see the effect rerun and print
"spread store.a"
there is still a shallow merge, but the ...
force solid to track changes to the object itself.
in other words it tracks all top level changes to the object we destructed/spread
3
setting a key of a store with an alternating types
object TO non object {} => ""
or
non object TO object null => {}
will trigger the effect, because there is no shallow merge
between object and non object value like ( 1 and {} can not be merged )
so here the value of the key is replaced and the
effect will re run
31 replies
createEffect vs createEffect + on
also here is some visualization of the behavior
https://playground.solidjs.com/anonymous/617b414c-f832-4284-a0e5-cf53b8a1f732
31 replies
createEffect vs createEffect + on
also console.log in effects might need a warning in docs it is a source of discrepancies in the learning process
https://discord.com/channels/722131463138705510/722131463889223772/1359995272637452378
31 replies
createEffect vs createEffect + on
spread operator
in this case the spread is like a short cut for iterating over the object or even array keys/values
top level
31 replies
Possible bug? Solidjs lazy() caches network errors
Yeah, it is trickier than I first assumed
vite, does not allow
import()
with an expression or a variable
you can use this /* @vite-ignore */
on the import to tell vite not to touch that import
then make your component a manual chunk, with a predictable name.11 replies
What's the most common way (or the idiomatic way) of refreshing access tokens in a Solid.js SPA?
I will not go with timer based solution whatsoever
one reason is that refresh logic might run more than you actually need. ( for idle application )
2nd is that timeout might not be accurate, and still need blocking logic if you don't want requests to fail.
so better to solve one problem and not 2
8 replies
What's the most common way (or the idiomatic way) of refreshing access tokens in a Solid.js SPA?
you need to put some logic in your token getter
and fetcher
getToken
1. if the token is valid(non-expired) return it
2. if the token expired, return a promise and start the refresh logic( refreshToken
).
3. in the fetcher, await the getToken
before fetching
4. if a response fails due to expired token
start the refresh logic.
while refreshing getToken
will return the promise
( you then initiate a retry logic, which will await the getToken until the refresh process is done)
refreshToken
should guard itself to only run if not already running.8 replies