-
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] Calling fresh() on Store does not do anything #402
Comments
Hihi I think we have a test that covers this case, check this test or the one right after. I think you should try to figure out what is different from your code. It’s hard for me to tell since it is a larger example with lots going on https://github.com/dropbox/Store/blob/e571b377e5c1c9b7200998d91f2415dcbd507756/store/src/test/java/com/dropbox/android/external/store4/impl/FlowStoreTest.kt#L166 |
I have this issue as well and I think the problem is that a store with |
Hi sorry. I don't quite understand. Could you reword your comment please |
Is it clear now? I accidentally typed Fetcher.ofFlow instead of Fetcher.of in the last sentence |
Aha that explains it. I'll take a look in am and write a failing test |
Seeing similar issue, when using rxjava:
Additionally I've noticed that even though we are passing rxjava scheduler it still, in some cases, going to run |
Hi folks, could you tell me what I am doing wrong with my test case? As in could you make this test fail please, I think I am not quite understanding what the issue is and would love a failing test case.
|
The issue with the wrong thread (dispatcher) could be reproduced by removing For example to confirm current thread:
Would print that we are on a wrong thread:
Similar test but with observe:
Shows correct thread and works fine without using await:
p.s. maybe it should be reported as a separate issue? |
@digitalbuddha I'm also facing a similar issue.
Here the first flow is still active while trying to refresh the same store. This is the output printed for this.
Here we can see that the Fetcher is not called again. The fresh call will never be complete here. I modified the above to see the issue more clearly.
Now the output is,
Here we can see that the Loading event is emitted for the second fresh call, but the fetcher is not called again and thus no data is emitted. Basically, when another flow for the same store is active, fresh calls are not working. If I cancel the first flow before calling fresh again, the output is printed correctly on unit tests.
But in my real app (Android) where I have a similar setup, even canceling the previous flow doesn't make the fetcher being called again. Store version used: 5.0.0-alpha03 |
An update regarding this. I actually subscribed to the same store's stream in two different places and I didn't cancel one of them while trying to call fetch again. When I cancel all of those before trying to do fetch again, fetcher is called properly. So the issue is, when there is an active subscriber to the store's flow somewhere, fetcher is not being called when calling fetch/cache with refresh true. |
Thanks @muthuraj57 👍🏽 Will take a look |
Hey @muthuraj57 - Sorry to be slow. Spent a few hours on this today. @digitalbuddha and I are meeting tomo and can sync then. In the interim can you give more context on your use case? I can repro with your test as written. However AFAICT rewriting your test to map outside of fetcher gives the expected result. |
Thanks for looking into this. My use case is, I have a Store let's call it Now at some point, I need to refresh the data from the first ViewModel, so I cancel the previous If I cancel the |
That part makes sense to me 👍🏽. What is the use case for having a fetcher stream another store? |
Let's say in a list and detail screen, I combine a few stores and fetch the data to populate the list screen. Now in the detail screen, I need to get the same data to display the details. To not duplicate the combine operator and all the code inside that, I moved those into a new store and gave it inside fetcher. So I'll use this new store to fetch data from the list screen and use the same store in the detail screen to get the cached data. |
Can you share a sample with me? Pipeline use case is something we have thought about. My email is [email protected] if you can't share publicly. I'd like to read closely to better understand real use case |
This seems relevant to the issue I am seeing also on iOS #657. Basically if you cancel then start a stream fast enough, you also end up not getting any data from the store. |
Sample app
Issue is recreated in sample app: https://github.com/dbobrzyk/StoreIssueSample
Describe the bug
When creating Store from the flow, data loads perfectly on init. But when requested to refresh the data (from button or swipe refresh) calling fresh() on store is doing nothing (nothing like the inside of the function was empty - just void).
Expected behaviour would be to get the new fresh data from repository and pass it to the VM.
To Reproduce
Expected behavior
After clicking the refresh button there should be request made to the Fake Service and new data should be loaded.
Screenshots
Instead of screenshoot I created sample app.
Smartphone (please complete the following information):
Additional context
After calling SampleRepository.kt line 42 inside of the function in line 23 is never called.
The text was updated successfully, but these errors were encountered: