Skip to content

Commit 9895223

Browse files
committed
Clarify that operator chaining order matters
ReactiveX/RxJava#3152
1 parent 6fb17b5 commit 9895223

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

documentation/observable.markdown

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ id: observable
1717
operators</a> to link Observables together and change their behaviors.
1818
</p>
1919
<figure>
20-
<figcaption><p>This documentation accompanies its explanations with &ldquo;marble diagrams.&rdquo; Here is how marble diagrams represent Observables and transformations of Observables:</p></figcaption>
20+
<figcaption><p>This documentation accompanies its explanations with &ldquo;marble diagrams.&rdquo; Here is how
21+
marble diagrams represent Observables and transformations of Observables:</p></figcaption>
2122
<img src="{{ site.url }}/assets/operators/legend.png" style="width:100%;" />
2223
</figure>
2324
<h4>See Also</h4>
@@ -223,3 +224,19 @@ myObservable.subscribe(myOnNext, myError, myComplete);
223224
These pages include information about some operators that are not part of the core of ReactiveX but are
224225
implemented in one or more of language-specific implementations and/or optional modules.
225226
</p>
227+
<h2>Chaining Operators</h2>
228+
<p>
229+
Most operators operate on an Observable and return an Observable. This allows you to apply these operators one
230+
after the other, in a chain. Each operator in the chain modifies the Observable that results from the operation
231+
of the previous operator.
232+
</p><p>
233+
There are other patterns, like the Builder Pattern, in which a variety of methods of a particular class
234+
operate on an item of that same class by modifying that object through the operation of the method. These
235+
patterns also allow you to chain the methods in a similar way. But while in the Builder Pattern, the order in
236+
which the methods appear in the chain does not usually matter, with the Observable operators <em>order
237+
matters</em>.
238+
</p><p>
239+
A chain of Observable operators do not operate independently on the original Observable that originates the
240+
chain, but they operate <em>in turn</em>, each one operating on the Observable generated by the operator
241+
immediately previous in the chain.
242+
</p>

documentation/operators.markdown

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,30 @@ title: ReactiveX - Operators
44
id: operators
55
---
66

7+
<h1>Introduction</h1>
8+
79
Each language-specific implementation of ReactiveX implements a set of operators. Although there is much overlap
810
between implementations, there are also some operators that are only implemented in certain implementations.
911
Also, each implementation tends to name its operators to resemble those of similar methods that are already
1012
familiar from other contexts in that language.
1113

14+
<h2>Chaining Operators</h2>
15+
16+
Most operators operate on an Observable and return an Observable. This allows you to apply these operators one
17+
after the other, in a chain. Each operator in the chain modifies the Observable that results from the operation
18+
of the previous operator.
19+
20+
There are other patterns, like the Builder Pattern, in which a variety of methods of a particular class operate
21+
on an item of that same class by modifying that object through the operation of the method. These patterns also
22+
allow you to chain the methods in a similar way. But while in the Builder Pattern, the order in which the
23+
methods appear in the chain does not usually matter, with the Observable operators <em>order matters</em>.
24+
25+
A chain of Observable operators do not operate independently on the original Observable that originates the
26+
chain, but they operate <em>in turn</em>, each one operating on the Observable generated by the operator
27+
immediately previous in the chain.
28+
29+
<h2>The Operators of ReactiveX</h2>
30+
1231
This page first lists what could be considered the &ldquo;core&rdquo; operators in ReactiveX, and links to
1332
pages that have more in-depth information on how these operators work and how particular language-specific
1433
ReactiveX versions have implemented these operators.

0 commit comments

Comments
 (0)