@@ -54,7 +54,7 @@ public class OperationCombineLatest {
54
54
* The aggregation function used to combine the source observable values.
55
55
* @return A function from an observer to a subscription. This can be used to create an observable from.
56
56
*/
57
- public static <T0 , T1 , R > Func1 <Observer <R >, Subscription > combineLatest (Observable <T0 > w0 , Observable <T1 > w1 , Func2 <T0 , T1 , R > combineLatestFunction ) {
57
+ public static <T0 , T1 , R > Func1 <Observer <? super R >, Subscription > combineLatest (Observable <? super T0 > w0 , Observable <? super T1 > w1 , Func2 <? super T0 , ? super T1 , ? extends R > combineLatestFunction ) {
58
58
Aggregator <R > a = new Aggregator <R >(Functions .fromFunc (combineLatestFunction ));
59
59
a .addObserver (new CombineObserver <R , T0 >(a , w0 ));
60
60
a .addObserver (new CombineObserver <R , T1 >(a , w1 ));
@@ -64,7 +64,7 @@ public static <T0, T1, R> Func1<Observer<R>, Subscription> combineLatest(Observa
64
64
/**
65
65
* @see #combineLatest(Observable w0, Observable w1, Func2 combineLatestFunction)
66
66
*/
67
- public static <T0 , T1 , T2 , R > Func1 <Observer <R >, Subscription > combineLatest (Observable <T0 > w0 , Observable <T1 > w1 , Observable <T2 > w2 , Func3 <T0 , T1 , T2 , R > combineLatestFunction ) {
67
+ public static <T0 , T1 , T2 , R > Func1 <Observer <? super R >, Subscription > combineLatest (Observable <? super T0 > w0 , Observable <? super T1 > w1 , Observable <? super T2 > w2 , Func3 <? super T0 , ? super T1 , ? super T2 , ? extends R > combineLatestFunction ) {
68
68
Aggregator <R > a = new Aggregator <R >(Functions .fromFunc (combineLatestFunction ));
69
69
a .addObserver (new CombineObserver <R , T0 >(a , w0 ));
70
70
a .addObserver (new CombineObserver <R , T1 >(a , w1 ));
@@ -75,7 +75,7 @@ public static <T0, T1, T2, R> Func1<Observer<R>, Subscription> combineLatest(Obs
75
75
/**
76
76
* @see #combineLatest(Observable w0, Observable w1, Func2 combineLatestFunction)
77
77
*/
78
- public static <T0 , T1 , T2 , T3 , R > Func1 <Observer <R >, Subscription > combineLatest (Observable <T0 > w0 , Observable <T1 > w1 , Observable <T2 > w2 , Observable <T3 > w3 , Func4 <T0 , T1 , T2 , T3 , R > combineLatestFunction ) {
78
+ public static <T0 , T1 , T2 , T3 , R > Func1 <Observer <? super R >, Subscription > combineLatest (Observable <? super T0 > w0 , Observable <? super T1 > w1 , Observable <? super T2 > w2 , Observable <? super T3 > w3 , Func4 <? super T0 , ? super T1 , ? super T2 , ? super T3 , ? extends R > combineLatestFunction ) {
79
79
Aggregator <R > a = new Aggregator <R >(Functions .fromFunc (combineLatestFunction ));
80
80
a .addObserver (new CombineObserver <R , T0 >(a , w0 ));
81
81
a .addObserver (new CombineObserver <R , T1 >(a , w1 ));
@@ -85,11 +85,11 @@ public static <T0, T1, T2, T3, R> Func1<Observer<R>, Subscription> combineLatest
85
85
}
86
86
87
87
private static class CombineObserver <R , T > implements Observer <T > {
88
- final Observable <T > w ;
89
- final Aggregator <R > a ;
88
+ final Observable <? super T > w ;
89
+ final Aggregator <? super R > a ;
90
90
private Subscription subscription ;
91
91
92
- public CombineObserver (Aggregator <R > a , Observable <T > w ) {
92
+ public CombineObserver (Aggregator <? super R > a , Observable <? super T > w ) {
93
93
this .a = a ;
94
94
this .w = w ;
95
95
}
@@ -122,11 +122,11 @@ public void onNext(T args) {
122
122
* whenever we have received an event from one of the observables, as soon as each Observable has received
123
123
* at least one event.
124
124
*/
125
- private static class Aggregator <R > implements Func1 <Observer <R >, Subscription > {
125
+ private static class Aggregator <R > implements Func1 <Observer <? super R >, Subscription > {
126
126
127
- private Observer <R > observer ;
127
+ private Observer <? super R > observer ;
128
128
129
- private final FuncN <R > combineLatestFunction ;
129
+ private final FuncN <? extends R > combineLatestFunction ;
130
130
private final AtomicBoolean running = new AtomicBoolean (true );
131
131
132
132
// Stores how many observers have already completed
@@ -135,15 +135,15 @@ private static class Aggregator<R> implements Func1<Observer<R>, Subscription> {
135
135
/**
136
136
* The latest value from each observer.
137
137
*/
138
- private final Map <CombineObserver <R , ?>, Object > latestValue = new ConcurrentHashMap <CombineObserver <R , ?>, Object >();
138
+ private final Map <CombineObserver <? extends R , ?>, Object > latestValue = new ConcurrentHashMap <CombineObserver <? extends R , ?>, Object >();
139
139
140
140
/**
141
141
* Ordered list of observers to combine.
142
142
* No synchronization is necessary as these can not be added or changed asynchronously.
143
143
*/
144
144
private final List <CombineObserver <R , ?>> observers = new LinkedList <CombineObserver <R , ?>>();
145
145
146
- public Aggregator (FuncN <R > combineLatestFunction ) {
146
+ public Aggregator (FuncN <? extends R > combineLatestFunction ) {
147
147
this .combineLatestFunction = combineLatestFunction ;
148
148
}
149
149
@@ -161,7 +161,7 @@ <T> void addObserver(CombineObserver<R, T> w) {
161
161
*
162
162
* @param w The observer that has completed.
163
163
*/
164
- <T > void complete (CombineObserver <R , T > w ) {
164
+ <T > void complete (CombineObserver <? extends R , ? super T > w ) {
165
165
int completed = numCompleted .incrementAndGet ();
166
166
// if all CombineObservers are completed, we mark the whole thing as completed
167
167
if (completed == observers .size ()) {
@@ -191,7 +191,7 @@ void error(Exception e) {
191
191
* @param w
192
192
* @param arg
193
193
*/
194
- <T > void next (CombineObserver <R , T > w , T arg ) {
194
+ <T > void next (CombineObserver <? extends R , ? super T > w , T arg ) {
195
195
if (observer == null ) {
196
196
throw new RuntimeException ("This shouldn't be running if an Observer isn't registered" );
197
197
}
@@ -224,7 +224,7 @@ <T> void next(CombineObserver<R, T> w, T arg) {
224
224
}
225
225
226
226
@ Override
227
- public Subscription call (Observer <R > observer ) {
227
+ public Subscription call (Observer <? super R > observer ) {
228
228
if (this .observer != null ) {
229
229
throw new IllegalStateException ("Only one Observer can subscribe to this Observable." );
230
230
}
0 commit comments