Skip to content

Instantly share code, notes, and snippets.

@marcusshepp
Created March 3, 2022 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusshepp/b9ea9759b53a4d50f3dc5edd6426e004 to your computer and use it in GitHub Desktop.
Save marcusshepp/b9ea9759b53a4d50f3dc5edd6426e004 to your computer and use it in GitHub Desktop.
SignalR Observable
public foo(): Observable<any> {
if (this.connection) {
const subject: Subject<any> = new Subject<any>();
this.connection.on('', (bar): void => {
subject.next(bar);
});
this.connection.onclose((err?: Error): void => {
if (err) {
subject.error(err);
} else {
subject.complete();
}
});
this.connection.start();
return subject;
}
return of(null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment