34
34
* before the {@code Flowable} begins emitting items.
35
35
* <p>
36
36
* <img width="640" height="510" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/publishConnect.png" alt="">
37
- *
37
+ * <p>
38
+ * When the upstream terminates, the {@code ConnectableFlowable} remains in this terminated state and,
39
+ * depending on the actual underlying implementation, relays cached events to late {@link Subscriber}s.
40
+ * In order to reuse and restart this {@code ConnectableFlowable}, the {@link #reset()} method has to be called.
41
+ * When called, this {@code ConnectableFlowable} will appear as fresh, unconnected source to new {@link Subscriber}s.
42
+ * Disposing the connection will reset the {@code ConnectableFlowable} to its fresh state and there is no need to call
43
+ * {@code reset()} in this case.
44
+ * <p>
45
+ * Note that although {@link #connect()} and {@link #reset()} are safe to call from multiple threads, it is recommended
46
+ * a dedicated thread or business logic manages the connection or resetting of a {@code ConnectableFlowable} so that
47
+ * there is no unwanted signal loss due to early {@code connect()} or {@code reset()} calls while {@code Subscriber}s are
48
+ * still being subscribed to to this {@code ConnectableFlowable} to receive signals from the get go.
49
+ * <p>
38
50
* @see <a href="https://github.com/ReactiveX/RxJava/wiki/Connectable-Observable-Operators">RxJava Wiki:
39
51
* Connectable Observable Operators</a>
40
52
* @param <T>
41
53
* the type of items emitted by the {@code ConnectableFlowable}
54
+ * @since 2.0.0
42
55
*/
43
56
public abstract class ConnectableFlowable <T > extends Flowable <T > {
44
57
@@ -53,6 +66,14 @@ public abstract class ConnectableFlowable<T> extends Flowable<T> {
53
66
*/
54
67
public abstract void connect (@ NonNull Consumer <? super Disposable > connection );
55
68
69
+ /**
70
+ * Resets this ConnectableFlowable into its fresh state if it has terminated.
71
+ * <p>
72
+ * Calling this method on a fresh or active {@code ConnectableFlowable} has no effect.
73
+ * @since 3.0.0
74
+ */
75
+ public abstract void reset ();
76
+
56
77
/**
57
78
* Instructs the {@code ConnectableFlowable} to begin emitting the items from its underlying
58
79
* {@link Flowable} to its {@link Subscriber}s.
0 commit comments