README
Description
Installation
npm i @bottlenose/rxsocketio --saveyarn add @bottlenose/rxsocketioCompatability
Documentation & Guides
Basic Usage
Last updated
npm i @bottlenose/rxsocketio --saveyarn add @bottlenose/rxsocketioLast updated
import {from} from 'rxjs';
import {conduit} from '@bottlenose/rxsocketio';
const messageIn$ = from([
{topic: 'message', body: 'yarrr'},
{topic: 'message', body: 'arrr matey'},
{topic: 'message', body: 'Vitamin C? Never heard of it.'},
]);
const socketConfig = {
url: 'http://localhost:9080/ws', // socket.io server
topics: ['message'], // topics to subscribe to. (Defaults to ['message']).
};
// the conduit operator sends messages from messageIn$ and emits messages
// from the server
const messageBack$ = messageIn$.pipe(conduit({...socketConfig}));
messageBack$.subscribe(console.log);
// {topic: 'message', body: 'Welcome Matey.'}
// {topic: 'message', body: 'Yo ho. Yo ho. I am a message from the server.'}