Skip to content

Instantly share code, notes, and snippets.

@mcgill-a
Last active September 25, 2023 12:36
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 mcgill-a/9c3614132b842f217fa8c97bdfa43e0e to your computer and use it in GitHub Desktop.
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
@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