Skip to content

Bug when using withLatestFrom with nonsynced streams #4

Open
@apaatsio

Description

@apaatsio

_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions