-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
112 lines (93 loc) · 2.16 KB
/
test.js
File metadata and controls
112 lines (93 loc) · 2.16 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* @flow */
import {
SUBSCRIBE_ALL,
SUBSCRIBE_CLOSED,
SUBSCRIBE_SUBSCRIBERS_ADDED,
SUBSCRIBE_SUBSCRIBERS_REMOVED,
} from './src/lib';
import registry, { hasPubChan } from './src/registry';
const id = Symbol.for('@test');
const chan = registry.get(id);
chan
.subscribe()
.to(SUBSCRIBE_SUBSCRIBERS_REMOVED)
.do((ref, ids, event, subscriber) => {
try {
console.log('Subscriber Removed! ', subscriber);
} catch (e) {
console.log('Error: ', e);
}
});
chan
.subscribe()
.to(SUBSCRIBE_CLOSED)
.do((ref, ids, event, subscriber) => {
console.log('Closed!');
ref.cancel();
});
// chan
// .subscribe()
// .to(SUBSCRIBE_SUBSCRIBERS_ADDED)
// .do((ref, ids, event, subscriber) => {
// console.log(
// 'Subscribers Added 2!: ',
// subscriber === ref.subscription,
// event,
// subscriber.keys,
// );
// });
// chan
// .subscribe()
// .to(SUBSCRIBE_SUBSCRIBERS_REMOVED)
// .do((ref, ids, subscriber, event) => {
// console.log('Subscriber Removed! ', subscriber.keys);
// console.log(chan.size);
// });
// chan
// .subscribe()
// .to(SUBSCRIBE_ALL)
// .do((ref, ids) => {
// console.log('Subscribe All Executes: ', ids);
// });
setTimeout(() => {
chan.close();
});
// chan
// .subscribe()
// .to('one')
// .do(() => console.log(2));
// chan
// .subscribe()
// .to('one')
// .do(() => console.log(3));
// console.log('Size: ', chan.size);
// const sub = chan
// .subscribe({ async: true })
// .to('test')
// .do((...args) => {
// console.log('Do One! ');
// })
// .do((ref, ...args) => {
// console.log('Test Received');
// sub.cancel();
// });
// const sub2 = chan
// .subscribe()
// .to('test')
// .do(() => {
// console.log('DO 3!');
// });
// chan
// .broadcast()
// .send('one')
// .then(() => {
// console.log('Broadcast Next');
// // chan.broadcast().send('two');
// console.log(hasPubChan(id));
// });
// console.log('hi');
// import { frozenSet } from "./src/lib/utils/freeze";
// const set = new Set([1, 2, 3]);
// const frozen = frozenSet(set);
// Set.prototype.add.call(frozen);
// // console.log(frozen);