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