ferry icon indicating copy to clipboard operation
ferry copied to clipboard

Improve loading state

Open smkhalsa opened this issue 3 years ago • 5 comments

The OperationResponse.loading state is currently set as a function of data and errors (i.e. if both are missing).

We should figure out how to improve this so that additional requests with the same ID update the loading state of previous responses.

smkhalsa avatar Nov 28 '20 14:11 smkhalsa

Can we pass a completer with the request to the stream and complete it after handling the response? Like passing context to the cache?

lotus-x avatar Jun 27 '21 20:06 lotus-x

How would this be different than simply subscribing to data events on the stream?

This issue is about switching the loading state back to true when a new compatible request is in flight (so you can show a loading indicator, for example).

smkhalsa avatar Jun 28 '21 08:06 smkhalsa

Are there any recommended workarounds until it is implemented in the library? It is important to know the loading status of paginated requests...

OmerGronich avatar Oct 20 '21 11:10 OmerGronich

Are there any recommended workarounds until it is implemented in the library?

Unfortunately not, but let us know if you come up with any.

I think the ultimate solution is to completely refactor the TypedLink model to maintain a response "state" (as an rxdart ValueStream) which includes the most recent operation result and loading state

This might also allow us to synchronously (when using in-memory store) provide data from the cache for the given request, enabling features that require sync data like Flutter hero animations.

smkhalsa avatar Oct 20 '21 11:10 smkhalsa

I think the loading state has a bad design which is especially troublesome with mutation calls. The initial loading state is true even if executeOnListen is set to false. It is important because we are disabling the button which calls the mutation based on the loading state, which is not returning the correct value.

manlyman29 avatar Dec 03 '22 10:12 manlyman29