import { Component , RunReturn } from './types' ; import { createDisposableSinks , createProxySinks , replicateSinks } from './sinks' ; import { Subscription } from 'most' ; import { createDispose } from './dispose' ; import { sync } from 'most-subject' ; export function run < Sources , Sinks extends object > ( main , effects ) { const disposableSubject = sync < void > ( ) ; const sinkProxies = { } as Sinks ; const proxySinks = createProxySinks < Sinks > ( sinkProxies , disposableSubject ) ; const sources = effects ( proxySinks ) ; const sinks = createDisposableSinks ( main ( sources ) , disposableSubject ) ; const subscriptions = replicateSinks ( sinks , sinkProxies ) ; const dispose = createDispose ( disposableSubject , sources , subscriptions ) ; return { sources , sinks , dispose } ; }