forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathag-channel-tests.ts
39 lines (30 loc) · 1.02 KB
/
ag-channel-tests.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
import AGChannel = require('ag-channel');
import AGSimpleBroker = require('ag-simple-broker');
import StreamDemux = require('stream-demux');
const broker = new AGSimpleBroker();
const exchange = broker.exchange();
const channel = new AGChannel<number>('dummy', exchange, new StreamDemux(), new StreamDemux());
(async () => {
await channel.listener('subscribe').once();
console.log('subscribed');
})();
// $ExpectType ChannelState
channel.state;
(async () => {
// tslint:disable-next-line: await-promise Bug in tslint: https://github.com/palantir/tslint/issues/3997
for await (const message of channel) {
// $ExpectType number
message;
}
})();
(async () => {
// tslint:disable-next-line: await-promise Bug in tslint: https://github.com/palantir/tslint/issues/3997
for await (const event of channel.listener('subscribe')) {
// $ExpectType number
event;
}
await channel.transmitPublish(`hello`);
})();
// $ExpectType number
channel.getBackpressure();
channel.close();