import { Observable , PartialObserver , Subscription } from 'rxjs' ; import { Emission } from '../shared/emission' ; import { Tracker } from '../shared/tracker' ; import { ResolveCallback , ErrorCallback , NotifyCallback } from '../shared/types' ; import { PinLike } from './pin-like' ; import group , { Group } from './group' ; /**
 *
 * Represents a partial reactive flow, with some entry pins going into it
 * and some exit pins coming out of it.
 *
 */ export abstract class PartialFlow extends Tracker implements PinLike { /**
     *
     * Override this to specify the entry pins of this partial flow.
     * Read more about this [here](https://connective.dev/docs/agent#implicit-connection).
     *
     */ abstract get entries ( ) : Group ; /**
     *
     * Override this to specify the exit pins of this partial flow.
     * Read more about this [here](https://connective.dev/docs/agent#implicit-connection).
     *
     */ abstract get exits ( ) : Group ; param pins returns from ( ... pins ) { return this . entries . from ( ... pins ) ; } param pins returns to ( ... pins ) { return this . exits . to ( ... pins ) ; } param pins returns serialFrom ( ... pins ) { return this . entries . serialFrom ( ... pins ) ; } param pins returns serialTo ( ... pins ) { return this . exits . serialTo ( ... pins ) ; } get observable ( ) : Observable < Emission > { return this . exits . observable ; } subscribe ( observer ? ) ; subscribe ( next ? , error ? , complete ? ) ; /**
     *
     * Subscribes to all of its exit pins. Returns a composite subscription of
     * all created subscriptions.
     *
     */ subscribe ( _ ? , __ ? , ___ ? ) { return this . exits . subscribe ( _ as any , __ , ___ ) ; } } export type PartialFlowFactory = ( ) => [ Group | PinLike [ ] , Group | PinLike [ ] ] ; class InlineFlow extends PartialFlow { entries : Group ; exits : Group ; constructor ( readonly factory ) { super ( ) ; let [ entries , exits ] = factory ( ) ; this . entries = ( entries instanceof Group ) ? entries : group ( ... entries ) ; this . exits = ( exits instanceof Group ) ? exits : group ( ... exits ) ; } } param factory export function partialFlow ( factory ) { return new InlineFlow ( factory ) ; } export default partialFlow ;