|
1 | 1 | import { OperatorDoc } from '../operator.model'; |
2 | 2 |
|
3 | 3 | 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: [] |
6 | 56 | }; |
0 commit comments