20
20
import java .util .concurrent .*;
21
21
import java .util .concurrent .atomic .AtomicBoolean ;
22
22
23
- import rx .annotations .Experimental ;
23
+ import rx .annotations .* ;
24
24
import rx .exceptions .*;
25
25
import rx .functions .*;
26
26
import rx .internal .operators .*;
27
27
import rx .internal .util .*;
28
28
import rx .observers .*;
29
- import rx .plugins .* ;
29
+ import rx .plugins .RxJavaHooks ;
30
30
import rx .schedulers .Schedulers ;
31
31
import rx .subscriptions .*;
32
32
33
33
/**
34
34
* Represents a deferred computation without any value but only indication for completion or exception.
35
35
*
36
36
* The class follows a similar event pattern as Reactive-Streams: onSubscribe (onError|onComplete)?
37
+ *
38
+ * @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
37
39
*/
38
- @ Experimental
40
+ @ Beta
39
41
public class Completable {
40
42
/** The actual subscription action. */
41
43
private final OnSubscribe onSubscribe ;
42
44
43
- /**
44
- * @deprecated Use {@link OnSubscribe} instead.
45
- */
46
- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
47
- public interface CompletableOnSubscribe extends Action1 <CompletableSubscriber > {
48
-
49
- }
50
-
51
- private static OnSubscribe fromOldOnSubscribe (final CompletableOnSubscribe onSubscribe ) {
52
- return new OnSubscribe () {
53
- @ Override
54
- public void call (final rx .CompletableSubscriber s ) {
55
- onSubscribe .call (toOldSubscriber (s ));
56
- }
57
- };
58
- }
59
-
60
45
/**
61
46
* Callback used for building deferred computations that takes a CompletableSubscriber.
62
47
*/
63
48
public interface OnSubscribe extends Action1 <rx .CompletableSubscriber > {
64
49
65
50
}
66
51
67
- /**
68
- * @deprecated Use {@link Operator} instead.
69
- */
70
- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
71
- public interface CompletableOperator extends Func1 <CompletableSubscriber , CompletableSubscriber > {
72
-
73
- }
74
-
75
- private static Operator fromOldOperator (final CompletableOperator operator ) {
76
- requireNonNull (operator );
77
- return new Operator () {
78
- @ Override
79
- public rx .CompletableSubscriber call (final rx .CompletableSubscriber subscriber ) {
80
- return fromOldSubscriber (operator .call (toOldSubscriber (subscriber )));
81
- }
82
- };
83
- }
84
-
85
52
/**
86
53
* Convenience interface and callback used by the lift operator that given a child CompletableSubscriber,
87
54
* return a parent CompletableSubscriber that does any kind of lifecycle-related transformations.
@@ -90,78 +57,6 @@ public interface Operator extends Func1<rx.CompletableSubscriber, rx.Completable
90
57
91
58
}
92
59
93
- /**
94
- * @deprecated Use {@link rx.CompletableSubscriber} instead.
95
- */
96
- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
97
- public interface CompletableSubscriber {
98
- /**
99
- * Called once the deferred computation completes normally.
100
- */
101
- void onCompleted ();
102
-
103
- /**
104
- * Called once if the deferred computation 'throws' an exception.
105
- * @param e the exception, not null.
106
- */
107
- void onError (Throwable e );
108
-
109
- /**
110
- * Called once by the Completable to set a Subscription on this instance which
111
- * then can be used to cancel the subscription at any time.
112
- * @param d the Subscription instance to call dispose on for cancellation, not null
113
- */
114
- void onSubscribe (Subscription d );
115
- }
116
-
117
- static rx .CompletableSubscriber fromOldSubscriber (final CompletableSubscriber subscriber ) {
118
- requireNonNull (subscriber );
119
- return new rx .CompletableSubscriber () {
120
- @ Override
121
- public void onCompleted () {
122
- subscriber .onCompleted ();
123
- }
124
-
125
- @ Override
126
- public void onError (Throwable e ) {
127
- subscriber .onError (e );
128
- }
129
-
130
- @ Override
131
- public void onSubscribe (Subscription d ) {
132
- subscriber .onSubscribe (d );
133
- }
134
- };
135
- }
136
-
137
- static CompletableSubscriber toOldSubscriber (final rx .CompletableSubscriber subscriber ) {
138
- requireNonNull (subscriber );
139
- return new CompletableSubscriber () {
140
- @ Override
141
- public void onCompleted () {
142
- subscriber .onCompleted ();
143
- }
144
-
145
- @ Override
146
- public void onError (Throwable e ) {
147
- subscriber .onError (e );
148
- }
149
-
150
- @ Override
151
- public void onSubscribe (Subscription d ) {
152
- subscriber .onSubscribe (d );
153
- }
154
- };
155
- }
156
-
157
- /**
158
- * @deprecated Use {@link Transformer} instead.
159
- */
160
- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
161
- public interface CompletableTransformer extends Transformer {
162
-
163
- }
164
-
165
60
/**
166
61
* Convenience interface and callback used by the compose operator to turn a Completable into another
167
62
* Completable fluently.
@@ -456,17 +351,6 @@ public static Completable concat(Observable<? extends Completable> sources, int
456
351
return create (new CompletableOnSubscribeConcat (sources , prefetch ));
457
352
}
458
353
459
- /**
460
- * Constructs a Completable instance by wrapping the given old onSubscribe callback.
461
- * @param onSubscribe the old CompletableOnSubscribe instance to wrap
462
- * @return a Completable instance
463
- * @deprecated Use {@link #create(OnSubscribe)}.
464
- */
465
- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
466
- public static Completable create (CompletableOnSubscribe onSubscribe ) {
467
- return create (fromOldOnSubscribe (onSubscribe ));
468
- }
469
-
470
354
/**
471
355
* Constructs a Completable instance by wrapping the given onSubscribe callback.
472
356
* @param onSubscribe the callback which will receive the CompletableSubscriber instances
@@ -1117,14 +1001,6 @@ protected Completable(OnSubscribe onSubscribe) {
1117
1001
this .onSubscribe = RxJavaHooks .onCreate (onSubscribe );
1118
1002
}
1119
1003
1120
- /**
1121
- * @deprecated Use {@link #Completable(OnSubscribe)}.
1122
- */
1123
- @ Deprecated // TODO Remove constructor after 1.2.0 release. It was never a stable API. Provided only for migration.
1124
- protected Completable (CompletableOnSubscribe onSubscribe ) {
1125
- this (fromOldOnSubscribe (onSubscribe ));
1126
- }
1127
-
1128
1004
/**
1129
1005
* Constructs a Completable instance with the given onSubscribe callback without calling the onCreate
1130
1006
* hook.
@@ -1136,19 +1012,6 @@ protected Completable(OnSubscribe onSubscribe, boolean useHook) {
1136
1012
this .onSubscribe = useHook ? RxJavaHooks .onCreate (onSubscribe ) : onSubscribe ;
1137
1013
}
1138
1014
1139
- /**
1140
- * Constructs a Completable instance with the given onSubscribe callback without calling the onCreate
1141
- * hook.
1142
- * @param onSubscribe the callback that will receive CompletableSubscribers when they subscribe,
1143
- * not null (not verified)
1144
- * @param useHook if false, RxJavaHooks.onCreate won't be called
1145
- * @deprecated Use {@link #Completable(OnSubscribe, boolean)}.
1146
- */
1147
- @ Deprecated // TODO Remove constructor after 1.2.0 release. It was never a stable API. Provided only for migration.
1148
- protected Completable (CompletableOnSubscribe onSubscribe , boolean useHook ) {
1149
- this (fromOldOnSubscribe (onSubscribe ), useHook );
1150
- }
1151
-
1152
1015
/**
1153
1016
* Returns a Completable that emits the a terminated event of either this Completable
1154
1017
* or the other Completable whichever fires first.
@@ -1422,17 +1285,6 @@ public void onSubscribe(Subscription d) {
1422
1285
});
1423
1286
}
1424
1287
1425
- /**
1426
- * Returns a Completable which calls the given onComplete callback if this Completable completes.
1427
- * @param onComplete the callback to call when this emits an onComplete event
1428
- * @return the new Completable instance
1429
- * @throws NullPointerException if onComplete is null
1430
- * @deprecated Use {@link #doOnCompleted(Action0)} instead.
1431
- */
1432
- @ Deprecated public final Completable doOnComplete (Action0 onComplete ) {
1433
- return doOnCompleted (onComplete );
1434
- }
1435
-
1436
1288
/**
1437
1289
* Returns a Completable which calls the given onCompleted callback if this Completable completes.
1438
1290
* @param onCompleted the callback to call when this emits an onComplete event
@@ -1599,34 +1451,6 @@ public void call(Throwable e) {
1599
1451
}, onTerminate , Actions .empty (), Actions .empty ());
1600
1452
}
1601
1453
1602
- /**
1603
- * Returns a completable that first runs this Completable
1604
- * and then the other completable.
1605
- * <p>
1606
- * This is an alias for {@link #concatWith(Completable)}.
1607
- * @param other the other Completable, not null
1608
- * @return the new Completable instance
1609
- * @throws NullPointerException if other is null
1610
- * @deprecated Use {@link #andThen(rx.Completable)} instead.
1611
- */
1612
- @ Deprecated
1613
- public final Completable endWith (Completable other ) {
1614
- return andThen (other );
1615
- }
1616
-
1617
- /**
1618
- * Returns an Observable that first runs this Completable instance and
1619
- * resumes with the given next Observable.
1620
- * @param <T> the value type of the next Observable
1621
- * @param next the next Observable to continue
1622
- * @return the new Observable instance
1623
- * @deprecated Use {@link #andThen(rx.Observable)} instead.
1624
- */
1625
- @ Deprecated
1626
- public final <T > Observable <T > endWith (Observable <T > next ) {
1627
- return andThen (next );
1628
- }
1629
-
1630
1454
/**
1631
1455
* Returns a Completable instance that calls the given onAfterComplete callback after this
1632
1456
* Completable completes normally.
@@ -1730,18 +1554,6 @@ public void onSubscribe(Subscription d) {
1730
1554
return null ;
1731
1555
}
1732
1556
1733
- /**
1734
- * Lifts a CompletableSubscriber transformation into the chain of Completables.
1735
- * @param onLift the lifting function that transforms the child subscriber with a parent subscriber.
1736
- * @return the new Completable instance
1737
- * @throws NullPointerException if onLift is null
1738
- * @deprecated Use {@link #lift(Operator)}.
1739
- */
1740
- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
1741
- public final Completable lift (CompletableOperator onLift ) {
1742
- return lift (fromOldOperator (onLift ));
1743
- }
1744
-
1745
1557
/**
1746
1558
* Lifts a CompletableSubscriber transformation into the chain of Completables.
1747
1559
* @param onLift the lifting function that transforms the child subscriber with a parent subscriber.
@@ -2200,22 +2012,11 @@ public void onSubscribe(Subscription d) {
2200
2012
return mad ;
2201
2013
}
2202
2014
2203
- private static void deliverUncaughtException (Throwable e ) {
2015
+ static void deliverUncaughtException (Throwable e ) {
2204
2016
Thread thread = Thread .currentThread ();
2205
2017
thread .getUncaughtExceptionHandler ().uncaughtException (thread , e );
2206
2018
}
2207
2019
2208
- /**
2209
- * Subscribes the given CompletableSubscriber to this Completable instance.
2210
- * @param s the CompletableSubscriber, not null
2211
- * @throws NullPointerException if s is null
2212
- * @deprecated Use {@link #unsafeSubscribe(rx.CompletableSubscriber)}.
2213
- */
2214
- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
2215
- public final void unsafeSubscribe (CompletableSubscriber s ) {
2216
- unsafeSubscribe (fromOldSubscriber (s ));
2217
- }
2218
-
2219
2020
/**
2220
2021
* Subscribes the given CompletableSubscriber to this Completable instance.
2221
2022
* @param s the CompletableSubscriber, not null
@@ -2268,7 +2069,7 @@ public final <T> void unsafeSubscribe(final Subscriber<T> s) {
2268
2069
* @param callOnStart if true, the Subscriber.onStart will be called
2269
2070
* @throws NullPointerException if s is null
2270
2071
*/
2271
- private final <T > void unsafeSubscribe (final Subscriber <T > s , boolean callOnStart ) {
2072
+ private <T > void unsafeSubscribe (final Subscriber <T > s , boolean callOnStart ) {
2272
2073
requireNonNull (s );
2273
2074
try {
2274
2075
if (callOnStart ) {
0 commit comments