Hullo JS
Search…
ofWebSocket
import { ofWebSocket } from '@hullo/browser'
Adapter for WebSocket class for Hullo.
1
import { ofWebSocket } from '@hullo/browser';
2
​
3
const ws = new WebSocket('ws://example.com');
4
const ws$ = ofWebSocket(ws);
5
ws$.subscribe({
6
next(data) {
7
if (typeof data === 'string') {
8
console.log('received', data);
9
}
10
}
11
});
12
// sending
13
ws$.next('hello πŸ‘‹')
Copied!
Last modified 2yr ago
Copy link