alt icon indicating copy to clipboard operation
alt copied to clipboard

Data Sources: use id/key for isLoading

Open jfsiii opened this issue 9 years ago • 4 comments

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.

jfsiii avatar Sep 11 '15 20:09 jfsiii

@taion had an idea for this, that source receives an id field so these could be tracked.

goatslacker avatar Sep 11 '15 21:09 goatslacker

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 avatar Sep 11 '15 22:09 taion

@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.

jfsiii avatar Oct 05 '15 19:10 jfsiii

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 ?

moimael avatar Feb 26 '16 10:02 moimael