import { Context , StreamState , Stream } from '@ceramicnetwork/common' ; import { Observable } from 'rxjs' ; import { HandlersMap } from '../handlers-map' ; import { StateLink } from './state-link' ; param context param handlersMap param state param update$ export function streamFromState < T extends Stream > ( context , handlersMap , state , update$ ? ) { const handler = handlersMap . get < T > ( state . type ) ; const state$ = new StateLink ( state , update$ ) ; const stream = new handler . stream_constructor ( state$ , context ) ; if ( ! update$ ) { stream . makeReadOnly ( ) ; } return stream ; }