File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
main/java/rx/internal/operators
test/java/rx/internal/operators Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ public void onNext(T t) {
80
80
}
81
81
};
82
82
child .add (parent );
83
- observable .subscribe (parent );
83
+ observable .unsafeSubscribe (parent );
84
84
}
85
85
86
86
public static <T > OnSubscribeSingle <T > create (Observable <T > observable ) {
Original file line number Diff line number Diff line change 15
15
*/
16
16
package rx .internal .operators ;
17
17
18
+ import static org .junit .Assert .assertFalse ;
19
+
20
+ import java .util .Collections ;
21
+ import java .util .NoSuchElementException ;
22
+ import java .util .concurrent .atomic .AtomicBoolean ;
23
+
18
24
import org .junit .Test ;
25
+
19
26
import rx .Observable ;
20
27
import rx .Single ;
28
+ import rx .functions .Action0 ;
21
29
import rx .observers .TestSubscriber ;
22
30
23
- import java .util .Collections ;
24
- import java .util .NoSuchElementException ;
25
-
26
31
public class OnSubscribeSingleTest {
27
32
28
33
@ Test
@@ -70,4 +75,19 @@ public void testRepeatObservableThrowsError() {
70
75
71
76
subscriber .assertError (IllegalArgumentException .class );
72
77
}
78
+
79
+ @ Test
80
+ public void testShouldUseUnsafeSubscribeInternallyNotSubscribe () {
81
+ TestSubscriber <String > subscriber = TestSubscriber .create ();
82
+ final AtomicBoolean unsubscribed = new AtomicBoolean (false );
83
+ Single <String > single = Observable .just ("Hello World!" ).doOnUnsubscribe (new Action0 () {
84
+
85
+ @ Override
86
+ public void call () {
87
+ unsubscribed .set (true );
88
+ }}).toSingle ();
89
+ single .unsafeSubscribe (subscriber );
90
+ subscriber .assertCompleted ();
91
+ assertFalse (unsubscribed .get ());
92
+ }
73
93
}
You can’t perform that action at this time.
0 commit comments