ferry
ferry copied to clipboard
Improve loading state
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.
Can we pass a completer with the request to the stream and complete it after handling the response? Like passing context to the cache?
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).
Are there any recommended workarounds until it is implemented in the library? It is important to know the loading status of paginated requests...
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.
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.