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

Commit fa65858

Browse files
committed
docs(operator-docs): Added Merge operator documentation
1 parent 1b46319 commit fa65858

File tree

1 file changed

+73
-3
lines changed

1 file changed

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

33
export const merge: OperatorDoc = {
4-
'name': 'merge',
5-
'operatorType': 'combination'
4+
name: "merge",
5+
operatorType: "combination",
6+
signature:
7+
"public merge(other: ObservableInput, concurrent: number, scheduler: Scheduler): Observable",
8+
parameters: [
9+
{
10+
name: "other",
11+
type: "ObservableInput",
12+
attribute: "",
13+
description: `An input Observable to merge with the source Observable. More than one input
14+
Observables may be given as argument.`
15+
},
16+
{
17+
name: "concurrent",
18+
type: "number",
19+
attribute: "optional, default: Number.POSITIVE_INFINITY",
20+
description: `Maximum number of input Observables being subscribed to concurrently.`
21+
},
22+
{
23+
name: "scheduler",
24+
type: "Scheduler",
25+
attribute: "optional, default: null",
26+
description: `The IScheduler to use for managing concurrency of input Observables.`
27+
}
28+
],
29+
marbleUrl: "http://reactivex.io/rxjs/img/merge.png",
30+
shortDescription: {
31+
description: `Creates an output Observable which concurrently emits all values
32+
from every given input Observable. <span class="informal">Flattens multiple Observables
33+
together by blending their values into one Observable.</span>`
34+
},
35+
walkthrough: {
36+
description: `
37+
<p><code>Merge</code> subscribes to each given input Observable (either the source or an
38+
Observable given as argument), and simply forwards (without doing any
39+
transformation) all the values from all the input Observables to the output
40+
Observable. The output Observable only completes once all input Observables
41+
have completed. Any error delivered by an input Observable will be immediately
42+
emitted on the output Observable.</p>
43+
`
44+
},
45+
examples: [
46+
{
47+
name: "Merge together two Observables: 1s interval and clicks",
48+
code: `
49+
const clicks = Rx.Observable.fromEvent(document, 'click');
50+
const timer = Rx.Observable.interval(1000);
51+
const clicksOrTimer = clicks.merge(timer);
52+
clicksOrTimer.subscribe(x => console.log(x));
53+
`,
54+
externalLink: {
55+
platform: "JSBin",
56+
url: "http://jsbin.com/wihafapiva/1/edit?js,output"
57+
}
58+
},
59+
{
60+
name: "Merge together 3 Observables, but only 2 run concurrently",
61+
code: `
62+
const timer1 = Rx.Observable.interval(1000).take(10);
63+
const timer2 = Rx.Observable.interval(2000).take(6);
64+
const timer3 = Rx.Observable.interval(500).take(10);
65+
const concurrent = 2; // the argument
66+
const merged = timer1.merge(timer2, timer3, concurrent);
67+
merged.subscribe(x => console.log(x));
68+
`,
69+
externalLink: {
70+
platform: "JSBin",
71+
url: "http://jsbin.com/midosuqaga/1/edit?js,output"
72+
}
73+
}
74+
],
75+
relatedOperators: ["mergeAll", "mergeMap", "mergeMapTo", "mergeScan"]
676
};

0 commit comments

Comments
 (0)