import { Observable } from 'rxjs' import { webSocket, WebSocketSubject, WebSocketSubjectConfig } from 'rxjs/webSocket' import { Update } from '../types' import { Source } from './source' export class WebsocketSource implements Source { private websocket$: WebSocketSubject> | undefined constructor ( private readonly url: string, ) { } watch$ (): Observable> { const fullConfig: WebSocketSubjectConfig> = { url: this.url, openObserver: { next: () => { console.log('WebSocket connection open') this.websocket$!.next('open message' as any) }, }, } this.websocket$ = webSocket(fullConfig) return this.websocket$ } }