-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
42 lines (37 loc) · 870 Bytes
/
app.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
// rxjs is global variable
const lg = console.log
const observable = new rxjs.Observable((subscriber) => {
console.log('Hi')
subscriber.next(1);
subscriber.next(2);
subscriber.next(3);
setTimeout(() => {
subscriber.next(4);
subscriber.complete();
}, 1000);
});
console.log('just before subscribe');
observable.subscribe({
next(x) {
console.log('got value ' + x);
},
error(err) {
console.error('something wrong occurred: ' + err);
},
complete() {
console.log('done');
},
});
observable.subscribe((x)=>{
console.log('x:', x)
})
observable.subscribe((y)=>{
console.log('y:',y)
})
console.log('just after subscribe');
lg('-------------------')
const observable2 = rxjs.from([10, 20, 30]);
const subscription2 = observable2.subscribe((x) => console.log(x));
// Later:
subscription2.unsubscribe();
lg('-------------------')