-
Notifications
You must be signed in to change notification settings - Fork 1
/
windowTime.js
51 lines (44 loc) · 980 Bytes
/
windowTime.js
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
const Observable = require('rxjs/Observable').Observable;
require('rxjs/add/observable/timer');
require('rxjs/add/observable/from');
require('rxjs/add/operator/map');
require('rxjs/add/operator/mergeAll');
require('rxjs/add/operator/windowTime');
const windowTime = require('rxjs/operators').windowTime;
const tap = require('rxjs/operators').tap;
const mergeAll = require('rxjs/operators').mergeAll;
const source = Observable.timer(0, 1000);
// All three give same result.
// source.windowTime(3000)
// .subscribe(subject => {
// console.log('hello');
// subject.subscribe(console.log);
// });
// source.windowTime(3000)
// .map(r => {
// console.log('hello');
// return r;
// })
// .mergeAll()
// .subscribe(console.log);
source.pipe(
windowTime(3000),
tap(() => console.log('hello'))
).pipe(mergeAll())
.subscribe(console.log);
/**
hello
0
1
2
hello
3
4
5
hello
6
7
8
hello
9
**/