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

Commit 2a1f608

Browse files
Merge pull request #184 from sumitarora/docs-withLatestFrom
docs(operators): add documentation for withLatestFrom
2 parents f77497f + 47585b1 commit 2a1f608

File tree

1 file changed

+42
-2
lines changed

1 file changed

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

33
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']
646
};

0 commit comments

Comments
 (0)