@gang-js/core
Version:
a state sharing algorithm
16 lines (15 loc) • 396 B
JavaScript
export class GangWebSocket {
constructor(parse, subject, send, close) {
this.parse = parse;
this.subject = subject;
this.send = send;
this.close = close;
}
subscribe(onMessage, error, complete) {
return this.subject.subscribe({
next: (e) => onMessage(this.parse(e.data)),
error,
complete
});
}
}