Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
RxJava handling multiple Observable results #775
PR that handles multiple values returned by the Observable.
I've seen lately remark that in order to use the current implementation you need to use Observable<List<T>>, which is quite counter intuitive since the Observable by itself can produce multiple results, so this PR tries to address this issue, by aggregating the results and postponing the actual moment when they are going to "applied" on the DeferredResult.
The only thing I was thinking of is whether arbitrary wrapping the values into a plain Object array is a good way to approach this.
Indeed this code could use some improvement.
The response of course would not be rendered until all items are accumulated. Alternatively for a more streaming scenario where each item is rendered with a message converter, something similar to the ResponseBodyEmitterReturnValueHandler could be done.
We've decided not to include built-in support in 4.3 and leave that to 5.0. We could have easily and cleanly added support for
I did however make some changes that should make addressing your internal needs easier. See this pull request. You could register a
I should clarify I didn't think it necessary to expose timeout customizations because Observable and Single have built-in timeout related capabilities that are probably sufficient. For example in your adapter code you can create DeferredResult and SseEmitter with some expanded timeout (say from 10 to 30 seconds) and combine that with the rx timeout operator to supply default values with some fluctuation per use case.
For indicating SSE, it would be easy enough to return
As to how to treat an
Hope this helps.