-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Downstream flows never complete for Fetcher Flows that don't emit anything #185
Comments
Are you using a source of truth? |
Yes I am using source of truth. |
I'm seeing this same issue. I use the StoreResponse to detect if the flow is loading from the network. If so, then I show a loading indicator on the UI. This works great when I use a nonFlowFetcher, but if I use my own flow that only emits when my cache has expired then I see this sequence: Cache Since the fetcher remains in a loading state, despite the operation finishing, the loading ui will never disappear. Here's a sample:
Expected: Fetcher to not appear to be in a never ending loading state when the flow is finished without emitting. Source of truth should load. |
What is the Because if you are passing Maybe we need to start modeling a |
I am using |
This prototypes a change where if Fetcher is a Flow and never emits, we can fallback to SoT. This change does break another test we have (StoreTest#testFreshUsesOnlyNetwork) which ensures that we don't use disk for fresh requests. These two use cases seems at odds as I can also anticipate some users expecting to see disk resutls if network returns an error. Issue: #185
The fix for this is actually easy, i prototyped it here: Yet it does break another test we have which ensures that we don't use SoT values for Another issue we have is that, we don't have a construct that'll change the loading state of the Fetcher without it emitting any values. We don't really model loading state so maybe it is OK and it can be constructed from receiving disk values in a |
actually that fallback should probably include cache as well, not just SoT |
maybe we can do something like this:
Where
and then you can call:
for this case or if you want timeout, you could do:
or we could also allow combining these
We should also avoid complicating things at some point and ship a beta :D but this seems like a legit practical use case |
Would these solutions also apply to StoreRequest.cached? From my example I'm using:
|
No this won't cover that actually 🤦♂️. We need a way to model Empty response for that case, which would require a new store response type. |
I'd need to think a little more about the StoreRequest.fresh scenario... But I wonder if the solution for StoreRequest.cached is simpler than creating a new StoreResponse type... What if we changed the cache StoreRequest signature to something like:
This way the logic to check if the network call should even be executed is handled before the fetcher flow is started, preventing the Loading state from getting stuck, or even starting at all. I would expect under this implementation that the fetcher flow should always emit something... Looking at it though, this change would affect fresh, cached, and skipMemory as the current refresh Boolean appears to be tied to the StoreRequest constructor... |
I like modeling For the cache case it will look like: For the fresh case it will look like: thoughts? |
Describe the bug
When a fetcher flow just completes without emitting any data the downstream flows will never complete. SourceOfTruth reader won't be called
To Reproduce
fetcher = { key -> flow {} }
Expected behavior
Store should detect when the fetcher flow completes and allow the rest of the process to continue as normal.
Store Version 4.0.0-alpha06
Additional context
Fetchers flows that don't emit anything are extremely useful when manually dealing with caches that can't utilize the OkHttp cache.
The text was updated successfully, but these errors were encountered: