Quick Start
npm
npm i @buccaneer/rxws --saveyarn
yarn add @buccaneer/rxwsSubscribe to messages from a server
import { share } from 'rxjs/operators';
import { messages, ws } from '@buccaneer/rxws';
const websocketParams = {
url: 'wss://mysite.com',
topics: ['message', 'news'],
};
const ws$ = ws(websocketParams).pipe(
share() // pipe the Observable to a Subject
);
// get a stream of messages from the server:
const message$ = ws$.pipe(
messages() // get all messages from the WebSocket.
);
message$.subscribe(console.log); // log messages from the serverPublish messages to a server
Handle interruptions to the client's connection
Next steps
Check out the full API.
Last updated
Was this helpful?