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

Commit 989fd3a

Browse files
Merge pull request #153 from natmegs/doc-creation-map
docs(operators): add documentation for operator map
2 parents 8e84e13 + 0ecd889 commit 989fd3a

File tree

1 file changed

+52
-2
lines changed
  • src/operator-docs/transformation

1 file changed

+52
-2
lines changed
Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,56 @@
11
import { OperatorDoc } from '../operator.model';
22

33
export const map: OperatorDoc = {
4-
'name': 'map',
5-
'operatorType': 'transformation'
4+
name: 'map',
5+
operatorType: 'transformation',
6+
signature: 'public map(project: Function, thisArg: any): Observable',
7+
parameters: [
8+
{
9+
name: 'project',
10+
type: '(value: T, index: number) => R',
11+
attribute: '',
12+
description: `The function to apply to each 'value' emitted by the source Observable. The 'index' parameter is the number 'i'
13+
for the i-th emission that has happened since the subscription, starting from the number '0'.`
14+
},
15+
{
16+
name: 'thisArg',
17+
type: 'any',
18+
attribute: 'optional',
19+
description:
20+
"An optional argument to define what this is in the 'project' function."
21+
}
22+
],
23+
marbleUrl: 'http://reactivex.io/rxjs/img/map.png',
24+
shortDescription: {
25+
description: `
26+
Applies a given <span class="markdown-code">project</span> function to each value emitted by the source
27+
Observable, and emits the resulting values as an Observable.
28+
`,
29+
extras: []
30+
},
31+
walkthrough: {
32+
description: `
33+
<p>
34+
Similar to the well known <span class="markdown-code">Array.prototype.map</span> function,
35+
this operator applies a projection to each value and emits that projection in the output
36+
Observable.
37+
</p>
38+
`
39+
},
40+
examples: [
41+
{
42+
name: 'Map every click to the clientX position of that click',
43+
code: `
44+
let clicks = Rx.Observable.fromEvent(document, 'click');
45+
let positions = clicks.map(ev => ev.clientX);
46+
positions.subscribe(x => console.log(x));
47+
`,
48+
externalLink: {
49+
platform: 'JSBin',
50+
url: 'http://jsbin.com/dutered/embed?js,console,output'
51+
}
52+
}
53+
],
54+
relatedOperators: ['mapTo', 'pluck'],
55+
additionalResources: []
656
};

0 commit comments

Comments
 (0)