|
1 | 1 | import { OperatorDoc } from '../operator.model'; |
2 | 2 |
|
3 | 3 | export const withLatestFrom: OperatorDoc = { |
4 | | - 'name': 'withLatestFrom', |
5 | | - 'operatorType': 'combination' |
| 4 | + name: 'withLatestFrom', |
| 5 | + operatorType: 'combination', |
| 6 | + signature: |
| 7 | + 'public withLatestFrom(other: ObservableInput, project: Function): Observable', |
| 8 | + marbleUrl: 'http://reactivex.io/rxjs/img/withLatestFrom.png', |
| 9 | + shortDescription: { |
| 10 | + description: `Combines the source Observable with other Observables to create an Observable whose values are |
| 11 | + calculated from the latest values of each, only when the source emits.`, |
| 12 | + extras: [ |
| 13 | + { |
| 14 | + type: 'Tip', |
| 15 | + text: `Whenever the source Observable emits a value, it computes a formula using that |
| 16 | + value plus the latest values from other input Observables, then emits the output of that formula.` |
| 17 | + } |
| 18 | + ] |
| 19 | + }, |
| 20 | + walkthrough: { |
| 21 | + description: ` |
| 22 | + <p><span class="markdown-code">withLatestFrom</span> combines each value from the source Observable (the instance) with the latest |
| 23 | + values from the other input Observables only when the source emits a value, optionally using |
| 24 | + a project function to determine the value to be emitted on the output Observable. All input |
| 25 | + Observables must emit at least one value before the output Observable will emit a value. |
| 26 | + </p> |
| 27 | + ` |
| 28 | + }, |
| 29 | + examples: [ |
| 30 | + { |
| 31 | + name: |
| 32 | + 'For each click event, tick every second from 0 to 3, with no concurrency', |
| 33 | + code: ` |
| 34 | + const clicks = Rx.Observable.fromEvent(document, 'click'); |
| 35 | + const higherOrder = clicks.map(ev => Rx.Observable.interval(1000).take(4)); |
| 36 | + const firstOrder = higherOrder.concatAll(); |
| 37 | + firstOrder.subscribe(x => console.log(x)); |
| 38 | + `, |
| 39 | + externalLink: { |
| 40 | + platform: 'JSBin', |
| 41 | + url: 'http://jsbin.com/wojoqenitu/1/embed?js,console,output' |
| 42 | + } |
| 43 | + } |
| 44 | + ], |
| 45 | + relatedOperators: ['combineLatest'] |
6 | 46 | }; |
0 commit comments