import { API } from '../core/api' ; import { streamHandler } from '../helpers/handlers' ; import { FeedItem , Block } from '../models' ; import { ReadableStream } from 'web-streams-polyfill/ponyfill' ; /**
 * Observe is an API to stream updates from a thread or all threads
 */ export default class Observe extends API { param types param thread returns async events ( types ? , thread ? ) { const response = await this . sendGet ( `observe${ thread ? `/${ thread }` : '' }` , undefined , { type : ( types || [ ] ) . join ( '|' ) } ) ; if ( ! response . body ) { throw Error ( 'Empty response stream' ) ; } return streamHandler < FeedItem > ( response . body as ReadableStream ) ; } }