Skip to content

Instantly share code, notes, and snippets.

@vladimir-ivanov
Last active June 5, 2021 07:54
Show Gist options
  • Save vladimir-ivanov/0f54c742b6d518647797a3ae6120e454 to your computer and use it in GitHub Desktop.
Save vladimir-ivanov/0f54c742b6d518647797a3ae6120e454 to your computer and use it in GitHub Desktop.
microsoft signalr stream converted to rxjs stream for greater flexibility
import {HubConnection} from '@microsoft/signalr';
//payload can be a one off payload or a Subject
export const getSignalRStreamRx = (hubConnection: HubConnection, operation: string, payload: any) => new Observable(observer => {
const subscription = hubConnection.stream(observer, operation, payload);
return {
unsubscribe: () => {
subscription.unsubscribe();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment