import { Subject , sync } from 'most-subject' ; import { get , set } from '../helpers' ; export function createDisposableSinks < Sinks > ( sinks = { } as Sinks , disposableSubject = sync < void > ( ) ) { return Object . keys ( sinks ) . reduce < Sinks > ( function createDisposableSink ( disposableSinks , sinkName ) : Sinks { const disposableSink = get ( sinks , sinkName ) . until ( disposableSubject ) ; return set < Subject < any > > ( disposableSinks , sinkName , disposableSink ) as Sinks ; } , { } as Sinks ) ; }