You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Zip, CombineLatest, and Amb operators of the Observable class each have an overload that accepts an Iterable<ObservableSource> and a Function<Array<Any>, R> where R is a type parameter. The problem is that the elements of the Iterable are copied into an Observable[] internally by the Observer classes implementing the operators. This causes an ArrayStoreException if one supplies any custom ObservableSource implementation that doesn't subclass Observable.
The equivalent functions for the other stream types don't have this restriction. I.e, the Zip implementation in Maybe copies the source values into a MaybeSource[] and avoids this problem.
A simple workaround is to wrap any ObservableSource. To fix the above example pass listOf(sourceA, sourceB).map { Observable.wrap(it) } to combineLatest.
The text was updated successfully, but these errors were encountered:
mgsholte
changed the title
a2.x: Zip, CombineLatest, and Amb operators throw when supplied with ObservableSource implementation that doesn't subclass Observable
2.x: Zip, CombineLatest, and Amb operators throw when supplied with ObservableSource implementation that doesn't subclass Observable
Dec 10, 2019
…bservableSource implementation that doesn't subclass Observable (#6754)
* 2.x: Zip, CombineLatest, and Amb operators throw when supplied with ObservableSource implementation that doesn't subclass Observable #6753
* 2.x: add tests for allowing arbitrary ObservableSource implementations
Issue found in version 2.2.15.
The Zip, CombineLatest, and Amb operators of the
Observable
class each have an overload that accepts anIterable<ObservableSource>
and aFunction<Array<Any>, R>
whereR
is a type parameter. The problem is that the elements of theIterable
are copied into anObservable[]
internally by theObserver
classes implementing the operators. This causes anArrayStoreException
if one supplies any customObservableSource
implementation that doesn't subclassObservable
.The equivalent functions for the other stream types don't have this restriction. I.e, the Zip implementation in
Maybe
copies the source values into aMaybeSource[]
and avoids this problem.Example kotlin code which reproduces the issue:
A simple workaround is to wrap any
ObservableSource
. To fix the above example passlistOf(sourceA, sourceB).map { Observable.wrap(it) }
tocombineLatest
.The text was updated successfully, but these errors were encountered: