Skip to content

Instantly share code, notes, and snippets.

@vivainio
Created March 19, 2020 16:08
Show Gist options
  • Save vivainio/64414e19cf9bfaa9cd7a98765683ba2f to your computer and use it in GitHub Desktop.
Save vivainio/64414e19cf9bfaa9cd7a98765683ba2f to your computer and use it in GitHub Desktop.
export class SignalrService {
constructor(private zone: NgZone) {
}
messages$ = new Subject<any>();
connect() {
const conn = $.hubConnection("/myapp/notifications", {
useDefaultPath: false
});
const hub = conn.createHubProxy("someroutinghub");
hub.on("response", (messageString: string) => {
this.zone.run(() => {
this.messages$.next(messageString);
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment