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

Commit 7fe3ef1

Browse files
committed
docs(operators): add documentation for mergeMap
1 parent f77497f commit 7fe3ef1

File tree

2 files changed

+89
-3
lines changed

2 files changed

+89
-3
lines changed

src/app/operators/components/operator-parameters/operator-parameters.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h2> Parameters </h2>
1313
<td> {{parameter.name}} </td>
1414
<td> {{parameter.type}} </td>
1515
<td> {{parameter.attribute}} </td>
16-
<td> {{parameter.description}} </td>
16+
<td [innerHTML]="parameter.description"></td>
1717
</tr>
1818
</tbody>
1919
</table>
+88-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,92 @@
11
import { OperatorDoc } from '../operator.model';
22

33
export const mergeMap: OperatorDoc = {
4-
'name': 'mergeMap',
5-
'operatorType': 'transformation'
4+
name: 'mergeMap',
5+
operatorType: 'transformation',
6+
signature: `public mergeMap(project: function(value: T, ?index: number): ObservableInput,
7+
resultSelector: function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any, concurrent: number): Observable`,
8+
parameters: [
9+
{
10+
name: 'project',
11+
type: 'function(value: T, ?index: number): ObservableInput',
12+
attribute: '',
13+
description:
14+
'A function that, when applied to an item emitted by the source Observable, returns an Observable.'
15+
},
16+
{
17+
name: 'resultSelector',
18+
type:
19+
'function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any',
20+
attribute: 'optional',
21+
description: `
22+
A function to produce the value on the output Observable based on the values and the indices of the source
23+
(outer) emission and the inner Observable emission. The arguments passed to this function are:
24+
<ul>
25+
<li>outerValue: the value that came from the source</li>
26+
<li>innerValue: the value that came from the projected Observable</li>
27+
<li>outerIndex: the "index" of the value that came from the source</li>
28+
<li>innerIndex: the "index" of the value from the projected Observable</li>
29+
</ul>
30+
`
31+
},
32+
{
33+
name: 'concurrent',
34+
type: 'number',
35+
attribute: 'optional default: Number.POSITIVE_INFINITY',
36+
description:
37+
'Maximum number of input Observables being subscribed to concurrently.'
38+
}
39+
],
40+
marbleUrl: 'http://reactivex.io/rxjs/img/mergeMap.png',
41+
shortDescription: {
42+
description:
43+
'Projects each source value to an Observable which is merged in the output Observable.',
44+
extras: [
45+
{
46+
type: 'Tip',
47+
text:
48+
'Maps each value to an Observable, then flattens all of these inner Observables using mergeAll.'
49+
}
50+
]
51+
},
52+
walkthrough: {
53+
description: `<p>Returns an Observable that emits items based on applying a function that you
54+
supply to each item emitted by the source Observable, where that function
55+
returns an Observable, and then merging those resulting Observables and
56+
emitting the results of this merger.</p>`
57+
},
58+
examples: [
59+
{
60+
name:
61+
'Map and flatten each letter to an Observable ticking every 1 second',
62+
code: `
63+
const letters = Rx.Observable.of('a', 'b', 'c');
64+
const result = letters.mergeMap(x =>
65+
Rx.Observable.interval(1000).map(i => x+i)
66+
);
67+
result.subscribe(x => console.log(x));
68+
// Results in the following:
69+
// a0
70+
// b0
71+
// c0
72+
// a1
73+
// b1
74+
// c1
75+
// continues to list a,b,c with respective ascending integers
76+
`,
77+
externalLink: {
78+
platform: 'JSBin',
79+
url: 'http://jsbin.com/hehivasepi/1/embed?js,console'
80+
}
81+
}
82+
],
83+
relatedOperators: [
84+
'concatMap',
85+
'exhaustMap',
86+
'merge',
87+
'mergeAll',
88+
'mergeMapTo',
89+
'mergeScan',
90+
'switchMap'
91+
]
692
};

0 commit comments

Comments
 (0)