Skip to content

Commit 6adc66f

Browse files
EnricoPiccijakovljevic-mladen
authored andcommitted
docs: update Operators overview (#6819)
Introduce the concept that what we normally call "operators", such as `map` or `filter`, are Pipeable Operator Factory functions which, when called, return a "real" Pipeable Operator. (cherry picked from commit a292214)
1 parent 25bde17 commit 6adc66f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs_app/content/guide/operators.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ RxJS is mostly useful for its _operators_, even though the Observable is the fou
66

77
Operators are **functions**. There are two kinds of operators:
88

9-
**Pipeable Operators** are the kind that can be piped to Observables using the syntax `observableInstance.pipe(operator())`. These include, [`filter(...)`](/api/operators/filter), and [`mergeMap(...)`](/api/operators/mergeMap). When called, they do not _change_ the existing Observable instance. Instead, they return a _new_ Observable, whose subscription logic is based on the first Observable.
9+
**Pipeable Operators** are the kind that can be piped to Observables using the syntax `observableInstance.pipe(operator)` or, more commonly, `observableInstance.pipe(operatorFactory())`. Operator factory functions include, [`filter(...)`](/api/operators/filter), and [`mergeMap(...)`](/api/operators/mergeMap).
10+
11+
When Pipeable Operators are called, they do not _change_ the existing Observable instance. Instead, they return a _new_ Observable, whose subscription logic is based on the first Observable.
1012

1113
<span class="informal">A Pipeable Operator is a function that takes an Observable as its input and returns another Observable. It is a pure operation: the previous Observable stays unmodified.</span>
1214

15+
<span class="informal">A Pipeable Operator Factory is a function that can take parameters to set the context and return a Pipeable Operator. The factory’s arguments belong to the operator’s lexical scope.</span>
16+
1317
A Pipeable Operator is essentially a pure function which takes one Observable as input and generates another Observable as output. Subscribing to the output Observable will also subscribe to the input Observable.
1418

1519
**Creation Operators** are the other kind of operator, which can be called as standalone functions to create a new Observable. For example: `of(1, 2, 3)` creates an observable that will emit 1, 2, and 3, one right after another. Creation operators will be discussed in more detail in a later section.

0 commit comments

Comments
 (0)