Created
March 3, 2022 01:57
-
-
Save marcusshepp/b9ea9759b53a4d50f3dc5edd6426e004 to your computer and use it in GitHub Desktop.
SignalR Observable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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