mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-26 10:21:53 +00:00
13 lines
374 B
TypeScript
13 lines
374 B
TypeScript
import { Observable, timeout } from 'rxjs'
|
|
import { webSocket } from 'rxjs/webSocket'
|
|
import { Update } from '../types'
|
|
import { Source } from './source'
|
|
|
|
export class WebsocketSource<T> implements Source<T> {
|
|
constructor(private readonly url: string) {}
|
|
|
|
watch$(): Observable<Update<T>> {
|
|
return webSocket<Update<T>>(this.url).pipe(timeout({ first: 60000 }))
|
|
}
|
|
}
|