SingleFlight does not work (See Example)
I'm trying to make a single flight request work, but I'm always getting two requests:
What am I missing here?
4 Replies
Try doing
createAsync(() => getItems()
and using reload
instead of revalidate
- revalidate
is basically just for client use
though i will mention using const items
as shared state isn't entirely reliable, there will be a few copies of it on the server that may not be producing the behaviour you expectThank you! I changed it to this, still the same behaviour. 😦
though i will mention using const items as shared state isn't entirely reliable, there will be a few copies of it on the server that may not be producing the behaviour you expectHaha of course, this is just for the minimal prototype here. But either way, items are getting fetched - and I understand SingleFlight would return that fetch with the action-response directly, right?
Oh actually SFM relies on you providing a preload function for the route
It executes the preloads for the route after the action
ohhh, that makes sense
thats missing in the docs 😄
it works now, thank you! 🙂
In case anyone runs into the same issue, here is a working, minimal example. 🙂