Skip to content
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 when using withLatestFrom with nonsynced streams #4

Open
apaatsio opened this issue Sep 21, 2018 · 0 comments
Open

Bug when using withLatestFrom with nonsynced streams #4

apaatsio opened this issue Sep 21, 2018 · 0 comments

Comments

@apaatsio
Copy link

_results = _query.distinct().asyncMap(api.get).asBroadcastStream();
_log = Observable(results)
.withLatestFrom(_query.stream, (_, query) => 'Results for $query')
.asBroadcastStream();

I didn't try to run the code but I think there's a bug here when two queries are made in quick succession.

Consider the following time line:

  1. query for "dog"
  2. call api.get("dog")
  3. query for "cat"
  4. call api.get("cat")
  5. receive API response for "dog"
  6. log "Results for cat" (because "cat" is the latest value in _query stream)
  7. receive API response for "cat"
  8. log "Results for cat"

That is, it logs "Results for cat" twice and never logs "Results for dog" because _query and _results streams are not synced/zipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant