Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

Commit c3e4561

Browse files
Merge pull request #141 from sumitarora/docs-merge-all
docs(operator-docs): Added MergeAll operator documentation
2 parents dde8c45 + 17e6b06 commit c3e4561

File tree

1 file changed

+74
-3
lines changed

1 file changed

+74
-3
lines changed
Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,77 @@
1-
import { OperatorDoc } from '../operator.model';
1+
import { OperatorDoc } from "../operator.model";
22

33
export const mergeAll: OperatorDoc = {
4-
'name': 'mergeAll',
5-
'operatorType': 'combination'
4+
name: "mergeAll",
5+
operatorType: "combination",
6+
signature: "public mergeAll(concurrent: number): Observable",
7+
parameters: [
8+
{
9+
name: "concurrent",
10+
type: "number",
11+
attribute: "optional, default: Number.POSITIVE_INFINITY",
12+
description: `Maximum number of input Observables being subscribed to concurrently.`
13+
}
14+
],
15+
marbleUrl: "http://reactivex.io/rxjs/img/mergeAll.png",
16+
shortDescription: {
17+
description: `Converts a higher-order Observable into a first-order Observable which concurrently
18+
delivers all values that are emitted on the inner Observables`,
19+
extras: [
20+
{
21+
type: "Tip",
22+
text: "Flattens an Observable-of-Observables."
23+
}
24+
]
25+
},
26+
walkthrough: {
27+
description: `
28+
<p><code>MergeAll</code> subscribes to an Observable that emits Observables,
29+
also known as a higher-order Observable. Each time it observes one of these emitted
30+
inner Observables, it subscribes to that and delivers all the values from the inner
31+
Observable on the output Observable. The output Observable only completes once all inner
32+
Observables have completed. Any error delivered by a inner Observable will be immediately
33+
emitted on the output Observable.</p>
34+
`
35+
},
36+
examples: [
37+
{
38+
name:
39+
"Spawn a new interval Observable for each click event, and blend their outputs as one Observable",
40+
code: `
41+
const clicks = Rx.Observable.fromEvent(document, 'click');
42+
const higherOrder = clicks.map((ev) => Rx.Observable.interval(1000));
43+
const firstOrder = higherOrder.mergeAll();
44+
firstOrder.subscribe(x => console.log(x));
45+
`,
46+
externalLink: {
47+
platform: "JSBin",
48+
url: "http://jsbin.com/lebidefocu/1/edit?js,output"
49+
}
50+
},
51+
{
52+
name:
53+
"Count from 0 to 9 every second for each click, but only allow 2 concurrent timers",
54+
code: `
55+
const clicks = Rx.Observable.fromEvent(document, 'click');
56+
const higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(10));
57+
const firstOrder = higherOrder.mergeAll(2);
58+
firstOrder.subscribe(x => console.log(x));
59+
`,
60+
externalLink: {
61+
platform: "JSBin",
62+
url: "http://jsbin.com/kokezoribu/edit?js,output"
63+
}
64+
}
65+
],
66+
relatedOperators: [
67+
"combineAll",
68+
"concatAll",
69+
"exhaust",
70+
"merge",
71+
"mergeMap",
72+
"mergeMapTo",
73+
"mergeScan",
74+
"switch",
75+
"zipAll"
76+
]
677
};

0 commit comments

Comments
 (0)