|
1 | 1 | import { OperatorDoc } from '../operator.model';
|
2 | 2 |
|
3 | 3 | export const mapTo: OperatorDoc = {
|
4 |
| - 'name': 'mapTo', |
5 |
| - 'operatorType': 'transformation' |
| 4 | + name: 'mapTo', |
| 5 | + operatorType: 'transformation', |
| 6 | + signature: 'public mapTo(value: any): Observable', |
| 7 | + parameters: [ |
| 8 | + { |
| 9 | + name: 'value', |
| 10 | + type: 'any', |
| 11 | + attribute: '', |
| 12 | + description: `The value to map each source value to.` |
| 13 | + } |
| 14 | + ], |
| 15 | + useInteractiveMarbles: true, |
| 16 | + marbleUrl: 'http://reactivex.io/rxjs/img/mapTo.png', |
| 17 | + shortDescription: { |
| 18 | + description: `Emits the given constant value on the output Observable every time the source Observable emits a value.` |
| 19 | + }, |
| 20 | + walkthrough: { |
| 21 | + description: `<p> |
| 22 | + Takes a constant |
| 23 | + <code>value</code> as argument, |
| 24 | + and emits that whenever the source Observable emits a value. |
| 25 | + In other words, ignores the actual source value, |
| 26 | + and simply uses the emission moment to know when to emit the given |
| 27 | + <code>value</code>. |
| 28 | + <p>` |
| 29 | + }, |
| 30 | + examples: [ |
| 31 | + { |
| 32 | + name: "Map every click to the string 'Hi'", |
| 33 | + code: ` |
| 34 | + import { fromEvent } from 'rxjs/observable/fromEvent'; |
| 35 | + import { mapTo } from 'rxjs/operators'; |
| 36 | +
|
| 37 | + const clicks = fromEvent(document, 'click'); |
| 38 | + const greetings = clicks.pipe(mapTo('Hi'); |
| 39 | + greetings.subscribe(x => console.log(x)); |
| 40 | + /* |
| 41 | + Example console output: |
| 42 | + Hi |
| 43 | + */ |
| 44 | + `, |
| 45 | + externalLink: { |
| 46 | + platform: 'JSBin', |
| 47 | + url: 'http://jsbin.com/seyibe/embed?js,console,output' |
| 48 | + } |
| 49 | + } |
| 50 | + ], |
| 51 | + relatedOperators: ['map'], |
| 52 | + additionalResources: [] |
6 | 53 | };
|
0 commit comments