-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite concat operation to not block on subscribe
The concat operator previously blocked on calling subscribe until all the sequences had finished. In quite some cases this results in unwanted (and unexpected) behaviour, such as when prefixing an infinite Observable with a fixed one, for example when using startWith (which calls concat): someInputStream.startWith(123).subscribe(x -> print(x)); This statement will block indefinitely if the input stream is infinite. Also on finite sequences it seems silly to have to wait for them to finish. In this new approach the incoming observables are put into a queue, instead of waiting for the whole sequence to finish. When the first observable completes, the next one is taken from the queue and subscribed to, and so on. The queue can be extended while processing the observables, and onCompleted is only called when both the source of observables has completed and all observables in the queue have been read.
- Loading branch information
Showing
1 changed file
with
88 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters