alt
alt copied to clipboard
Data Sources: use id/key for isLoading
Ideally, a Source could supply a key/id for the remote
fetch to allow more granular loading tracking.
For example, a PostsSource
could differentiate between fetching post X vs post Y instead of simply any Posts-related fetch is in progress.
This way, the source could use a key of 'post-id-x'
or serialize the params for a key like '{"user":"x","count":10}'
.
isLoading()
could retain the same behavior, but gain isLoading(key)
for checking a specific key.
@taion had an idea for this, that source receives an id
field so these could be tracked.
I have essentially a copy of the behavior from Marty (rip) in #400, where each fetch operation is assigned an id
. That sort of handles both this and #483, in that only one fetch for a given id
could be active at any point in time, and that if you tried to submit a fetch for an id
that already had a pending fetch, that nothing would happen.
Is that the pattern you're trying to achieve?
@taion yes, that's the pattern. With #393 & #400 stalled, I opened this to track the behavior, regardless of the way it's ultimately implemented.
I am currently hitting this issue, I can't launch multiple requests at the same time using the same datasource and isLoading resulting in either one or the other request to update my store. Is there a workaround ?