Skip to content

Commit bcc419c

Browse files
authored
2.x: Add Subject and Processor marbles (#5816)
1 parent eb426fd commit bcc419c

9 files changed

+59
-13
lines changed

src/main/java/io/reactivex/processors/AsyncProcessor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
/**
2626
* Processor that emits the very last value followed by a completion event or the received error
2727
* to {@link Subscriber}s.
28-
*
29-
* <p>The implementation of onXXX methods are technically thread-safe but non-serialized calls
28+
* <p>
29+
* <img width="640" height="239" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/AsyncProcessor.png" alt="">
30+
* <p>
31+
* The implementation of onXXX methods are technically thread-safe but non-serialized calls
3032
* to them may lead to undefined state in the currently subscribed Subscribers.
3133
*
3234
* @param <T> the value type

src/main/java/io/reactivex/processors/PublishProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* Processor that multicasts all subsequently observed items to its current {@link Subscriber}s.
2828
*
2929
* <p>
30-
* <img width="640" height="405" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/S.PublishSubject.png" alt="">
30+
* <img width="640" height="278" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/PublishProcessor.png" alt="">
3131
*
3232
* <p>The processor does not coordinate backpressure for its subscribers and implements a weaker onSubscribe which
3333
* calls requests Long.MAX_VALUE from the incoming Subscriptions. This makes it possible to subscribe the PublishProcessor

src/main/java/io/reactivex/processors/ReplayProcessor.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,31 @@
3030
/**
3131
* Replays events to Subscribers.
3232
* <p>
33-
* <img width="640" height="405" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/S.ReplaySubject.png" alt="">
34-
*
33+
* The {@code ReplayProcessor} supports the following item retainment strategies:
34+
* <ul>
35+
* <li>{@link #create()} and {@link #create(int)}: retains and replays all events to current and
36+
* future {@code Subscriber}s.
37+
* <p>
38+
* <img width="640" height="269" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/ReplayProcessor.u.png" alt="">
39+
* <p>
40+
* <img width="640" height="345" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/ReplayProcessor.ue.png" alt="">
41+
* </li>
42+
* <li>{@link #createWithSize(int)}: retains at most the given number of items and replays only these
43+
* latest items to new {@code Subscriber}s.
44+
* <p>
45+
* <img width="640" height="332" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/ReplayProcessor.n.png" alt="">
46+
* </li>
47+
* <li>{@link #createWithTime(long, TimeUnit, Scheduler)}: retains items no older than the specified time
48+
* and replays them to new {@code Subscriber}s (which could mean all items age out).
49+
* <p>
50+
* <img width="640" height="415" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/ReplayProcessor.t.png" alt="">
51+
* </li>
52+
* <li>{@link #createWithTimeAndSize(long, TimeUnit, Scheduler, int)}: retaims no more than the given number of items
53+
* which are also no older than the specified time and replays them to new {@code Subscriber}s (which could mean all items age out).
54+
* <p>
55+
* <img width="640" height="404" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/ReplayProcessor.nt.png" alt="">
56+
* </li>
57+
* </ul>
3558
* <p>
3659
* The ReplayProcessor can be created in bounded and unbounded mode. It can be bounded by
3760
* size (maximum number of elements retained at most) and/or time (maximum age of elements replayed).

src/main/java/io/reactivex/subjects/AsyncSubject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
/**
2727
* A Subject that emits the very last value followed by a completion event or the received error to Observers.
2828
* <p>
29+
* <img width="640" height="239" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/AsyncSubject.png" alt="">
30+
* <p>
2931
* This subject does not have a public constructor by design; a new empty instance of this
3032
* {@code AsyncSubject} can be created via the {@link #create()} method.
3133
* <p>

src/main/java/io/reactivex/subjects/CompletableSubject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
/**
2525
* Represents a hot Completable-like source and consumer of events similar to Subjects.
2626
* <p>
27+
* <img width="640" height="243" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/CompletableSubject.png" alt="">
28+
* <p>
2729
* This subject does not have a public constructor by design; a new non-terminated instance of this
2830
* {@code CompletableSubject} can be created via the {@link #create()} method.
2931
* <p>

src/main/java/io/reactivex/subjects/MaybeSubject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
/**
2525
* Represents a hot Maybe-like source and consumer of events similar to Subjects.
2626
* <p>
27+
* <img width="640" height="164" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/MaybeSubject.png" alt="">
28+
* <p>
2729
* This subject does not have a public constructor by design; a new non-terminated instance of this
2830
* {@code MaybeSubject} can be created via the {@link #create()} method.
2931
* <p>

src/main/java/io/reactivex/subjects/PublishSubject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* A Subject that emits (multicasts) items to currently subscribed {@link Observer}s and terminal events to current
2626
* or late {@code Observer}s.
2727
* <p>
28-
* <img width="640" height="405" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/S.PublishSubject.png" alt="">
28+
* <img width="640" height="281" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/PublishSubject.png" alt="">
2929
* <p>
3030
* This subject does not have a public constructor by design; a new empty instance of this
3131
* {@code PublishSubject} can be created via the {@link #create()} method.

src/main/java/io/reactivex/subjects/ReplaySubject.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,36 @@
2929
/**
3030
* Replays events (in a configurable bounded or unbounded manner) to current and late {@link Observer}s.
3131
* <p>
32-
* <img width="640" height="405" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/S.ReplaySubject.png" alt="">
33-
* <p>
3432
* This subject does not have a public constructor by design; a new empty instance of this
3533
* {@code ReplaySubject} can be created via the following {@code create} methods that
3634
* allow specifying the retention policy for items:
3735
* <ul>
3836
* <li>{@link #create()} - creates an empty, unbounded {@code ReplaySubject} that
39-
* caches all items and the terminal event it receives.</li>
37+
* caches all items and the terminal event it receives.
38+
* <p>
39+
* <img width="640" height="299" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/ReplaySubject.u.png" alt="">
40+
* <p>
41+
* <img width="640" height="398" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/ReplaySubject.ue.png" alt="">
42+
* </li>
4043
* <li>{@link #create(int)} - creates an empty, unbounded {@code ReplaySubject}
41-
* with a hint about how many <b>total</b> items one expects to retain.</li>
44+
* with a hint about how many <b>total</b> items one expects to retain.
45+
* </li>
4246
* <li>{@link #createWithSize(int)} - creates an empty, size-bound {@code ReplaySubject}
43-
* that retains at most the given number of the latest item it receives.</li>
47+
* that retains at most the given number of the latest item it receives.
48+
* <p>
49+
* <img width="640" height="420" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/ReplaySubject.n.png" alt="">
50+
* </li>
4451
* <li>{@link #createWithTime(long, TimeUnit, Scheduler)} - creates an empty, time-bound
45-
* {@code ReplaySubject} that retains items no older than the specified time amount.</li>
52+
* {@code ReplaySubject} that retains items no older than the specified time amount.
53+
* <p>
54+
* <img width="640" height="415" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/ReplaySubject.t.png" alt="">
55+
* </li>
4656
* <li>{@link #createWithTimeAndSize(long, TimeUnit, Scheduler, int)} - creates an empty,
4757
* time- and size-bound {@code ReplaySubject} that retains at most the given number
48-
* items that are also not older than the specified time amount.</li>
58+
* items that are also not older than the specified time amount.
59+
* <p>
60+
* <img width="640" height="404" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/ReplaySubject.nt.png" alt="">
61+
* </li>
4962
* </ul>
5063
* <p>
5164
* Since a {@code Subject} is conceptionally derived from the {@code Processor} type in the Reactive Streams specification,

src/main/java/io/reactivex/subjects/SingleSubject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
/**
2525
* Represents a hot Single-like source and consumer of events similar to Subjects.
2626
* <p>
27+
* <img width="640" height="236" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/SingleSubject.png" alt="">
28+
* <p>
2729
* This subject does not have a public constructor by design; a new non-terminated instance of this
2830
* {@code SingleSubject} can be created via the {@link #create()} method.
2931
* <p>

0 commit comments

Comments
 (0)