15
15
*/
16
16
package rx .internal .operators ;
17
17
18
- import java .util .ArrayList ;
19
- import java .util .Collections ;
20
- import java .util .List ;
21
- import rx .Observable ;
18
+ import java .util .*;
19
+
20
+ import rx .*;
22
21
import rx .Observable .Operator ;
22
+ import rx .Observable ;
23
23
import rx .Observer ;
24
- import rx .Subscriber ;
25
- import rx .functions .Func0 ;
26
24
import rx .observers .SerializedSubscriber ;
27
- import rx .observers .Subscribers ;
28
25
29
26
/**
30
27
* Creates non-overlapping windows of items where each window is terminated by
34
31
* @param <U> the boundary value type
35
32
*/
36
33
public final class OperatorWindowWithObservable <T , U > implements Operator <Observable <T >, T > {
37
- final Func0 <? extends Observable <? extends U >> otherFactory ;
34
+ final Observable <U > other ;
38
35
39
- public OperatorWindowWithObservable (Func0 <? extends Observable <? extends U >> otherFactory ) {
40
- this .otherFactory = otherFactory ;
41
- }
42
36
public OperatorWindowWithObservable (final Observable <U > other ) {
43
- this .otherFactory = new Func0 <Observable <U >>() {
44
-
45
- @ Override
46
- public Observable <U > call () {
47
- return other ;
48
- }
49
-
50
- };
37
+ this .other = other ;
51
38
}
52
39
53
40
@ Override
54
41
public Subscriber <? super T > call (Subscriber <? super Observable <T >> child ) {
55
42
56
- Observable <? extends U > other ;
57
- try {
58
- other = otherFactory .call ();
59
- } catch (Throwable e ) {
60
- child .onError (e );
61
- return Subscribers .empty ();
62
- }
63
-
64
43
SourceSubscriber <T > sub = new SourceSubscriber <T >(child );
65
44
BoundarySubscriber <T , U > bs = new BoundarySubscriber <T , U >(child , sub );
66
45
46
+ child .add (sub );
47
+ child .add (bs );
48
+
67
49
sub .replaceWindow ();
68
50
69
51
other .unsafeSubscribe (bs );
@@ -88,7 +70,6 @@ static final class SourceSubscriber<T> extends Subscriber<T> {
88
70
List <Object > queue ;
89
71
90
72
public SourceSubscriber (Subscriber <? super Observable <T >> child ) {
91
- super (child );
92
73
this .child = new SerializedSubscriber <Observable <T >>(child );
93
74
this .guard = new Object ();
94
75
}
@@ -288,7 +269,6 @@ void error(Throwable e) {
288
269
static final class BoundarySubscriber <T , U > extends Subscriber <U > {
289
270
final SourceSubscriber <T > sub ;
290
271
public BoundarySubscriber (Subscriber <?> child , SourceSubscriber <T > sub ) {
291
- super (child );
292
272
this .sub = sub ;
293
273
}
294
274
0 commit comments