When consuming SignalR based services I wanted to be able to treat receiving data as an observable stream. This library provides a thin wrapper to allow consumption of SignalR services using RxJS Observables.
Refer to the RxJS docs for that.
Refer to the ASP.NET SignalR docs.
This package relies on signalr and rxjs packages.
Install using npm:
npm install observable-signalr --save
Create using factory method:
import { createSignalRHub } from 'observable-signalr';
const hub = createSignalRHub('{hubName}');
Create using constructor:
import { SignalRHub } from 'observable-signalr';
const hub = new SignalRHub('{hubName}');
import { createSignalRHub } from 'observable-signalr';
const hub = createSignalRHub('{hubName}');
hub.on('{name of event/method}').subscribe(data => {
// Perform logic here
});
hub.start();
import { createSignalRHub } from 'observable-signalr';
const hub = createSignalRHub('{hubName}');
hub.start();
hub.send('{name of event/method}', {});