0.1.2 • Published 4 years ago
@jaenster/channels v0.1.2
Simple channel
Push something in, get something out
import {Channel, Client} from '@jaenster/channels'
describe('channel', () => {
    const channel = Channel.factory<string>();
    const arr = [];
    test('can send message', async () => {
        const alice = new ChannelClient(channel);
        const bob = new ChannelClient(channel);
        alice.out('test');
        let sender: ChannelClient<string>;
        bob.on('data', (a, who) => {
            sender = who;
            arr.push(a)
        })
        expect(arr).toHaveLength(0);
        await delay();
        expect(arr).toHaveLength(1);
        expect(sender).toBe(alice);
    });
});0.1.2
4 years ago