0.10.2 • Published 4 months ago

megaphone-client v0.10.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Megaphone Client

Typescript and Javascript library to subscribe to Megaphone channels.

Usage

Example usage:

import { MegaphonePoller } from 'megaphone-client';
import { firstValueFrom } from 'rxjs';

const poller = new MegaphonePoller('http://localhost:3000');
const o = await poller.newUnboundedStream<{ message: string, sender: string }>(async channel => {
    let res = await fetch('http://localhost:3040/room/test', {
        method: 'POST',
        headers: {
            ...(channel ? { 'use-channel': channel } : {}),
        },
    }).then(res => res.json());

    return {
        channelId: res.channelUuid,
        streamIds: ['new-message'],
    }
});

const chunk = await firstValueFrom(o);
console.log(chunk.body.message);

See Megaphone demo for more complete examples.

0.10.1

4 months ago

0.10.2

4 months ago

0.9.3

4 months ago