Last active
September 25, 2023 12:36
-
-
Save mcgill-a/9c3614132b842f217fa8c97bdfa43e0e to your computer and use it in GitHub Desktop.
A minimal frontend service for listening to web socket changes in Angular
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
@Injectable({ providedIn: 'root' }) | |
export class SocketService { | |
constructor(private socket: Socket) {} | |
public readonly userChange = this.socket | |
.fromEvent<string>(SocketChannel.user) | |
.pipe(map((x) => JSON.parse(x) as UserChange)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment