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
It seems impossible to subscribe several Observers to the same GroupedObservable, as demonstrated in the following snipet:
Observable.range(1, 100).groupBy(new Func1<Integer, String>() {
public String call(final Integer integer) {
return integer > 50 ? "big" : "small";
}
}).subscribe(new Action1<GroupedObservable<String, Integer>>() {
public void call(final GroupedObservable<String, Integer> objectIntegerGroupedObservable) {
// First subscription, if left alone works flawlessly
objectIntegerGroupedObservable.subscribe(new Action1<Integer>() {
public void call(final Integer integer) {
System.out.println("first subscriber: "+integer);
}
});
// Second subscription, fails and break the first one too
objectIntegerGroupedObservable.subscribe(new Observer<Integer>() {
public void onCompleted() {}
public void onError(final Throwable e) { System.out.println(e); }
public void onNext(final Integer args) { }
});
}
});
When providing an onError implementation to the second subscription, we can see a "java.lang.IllegalStateException: Can not set subscription more than once."
This seems unique to GroupedObservable, as other Observables (direct, or resulting of transformation) can be subscribed to multiples times.
Is this a bug or a desired behavior ? In the latter case, I am interested in the rationals and alternatives.
I am currently using publish and/or replay on the resulting GroupedObservables before any further processing but it clutters the code with implemetation detailsm imho.
Thanks for your time and energy !
The text was updated successfully, but these errors were encountered:
Hi. Yes, it is the common single-subscription bug. If you can, upgrade to the most recent version (0.17).
A few of the older operators have this issue. For a workaround, I suggest using groupByUntil() with a Observable.never() duration selector. However, this operator has a synchronization bug, therefore, don't use it with any other kind of duration selector.
It seems impossible to subscribe several Observers to the same GroupedObservable, as demonstrated in the following snipet:
When providing an onError implementation to the second subscription, we can see a "java.lang.IllegalStateException: Can not set subscription more than once."
This seems unique to GroupedObservable, as other Observables (direct, or resulting of transformation) can be subscribed to multiples times.
Is this a bug or a desired behavior ? In the latter case, I am interested in the rationals and alternatives.
I am currently using publish and/or replay on the resulting GroupedObservables before any further processing but it clutters the code with implemetation detailsm imho.
Thanks for your time and energy !
The text was updated successfully, but these errors were encountered: