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