flutter_bloc_tutorial icon indicating copy to clipboard operation
flutter_bloc_tutorial copied to clipboard

Bug when using withLatestFrom with nonsynced streams

Open apaatsio opened this issue 7 years ago • 0 comments

https://github.com/tensor-programming/flutter_bloc_tutorial/blob/7c1cea39047a700f677e5ed1165ea091b2f619ae/lib/bloc.dart#L20-L24

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.

apaatsio avatar Sep 21 '18 09:09 apaatsio