import { Observable , PartialObserver , Subscription } from 'rxjs' ; import { map } from 'rxjs/operators' ; import { Emission } from '../shared/emission' ; import { Tracker } from '../shared/tracker' ; import { ResolveCallback , ErrorCallback , NotifyCallback } from '../shared/types' ; import { Group , traverseFrom , traverseTo } from './group' ; import { PinLike } from './pin-like' ; import { PartialFlow } from './partial-flow' ; /**
 *
 * The base class for [pins](https://connective.dev/docs/pin).
 *
 */ export abstract class BasePin extends Tracker implements PinLike { param _ abstract connect ( _ ) ; /**
     *
     * The underlying observable of the pin. You can use this property
     * to access the [emissions](https://connective.dev/docs/emission) instead of
     * values, or to connect your CONNECTIVE flow into another observable sequence.
     *
     */ abstract observable : Observable < Emission > ; param pins returns to ( ... pins ) { pins . forEach ( pin => pin . from ( this ) ) ; return traverseTo ( ... pins ) ; } param pins returns from ( ... pins ) { pins . forEach ( pin => { if ( pin instanceof Group ) pin . pins . forEach ( p => this . connect ( p ) ) ; else if ( pin instanceof PartialFlow ) pin . exits . pins . forEach ( o => this . connect ( o ) ) ; else this . connect ( pin ) ; } ) ; return traverseFrom ( ... pins ) ; } param pins returns serialTo ( ... pins ) { pins . forEach ( pin => { if ( pin instanceof PartialFlow ) { if ( pin . entries . pins . length > 0 ) pin . entries . pins [ 0 ] . from ( this ) ; } else pin . from ( this ) ; } ) ; return traverseTo ( ... pins ) ; } param pins returns serialFrom ( ... pins ) { pins . forEach ( pin => { if ( pin instanceof PartialFlow ) { if ( pin . exits . pins . length > 0 ) this . connect ( pin . exits . pins [ 0 ] ) ; } else this . connect ( pin ) ; } ) ; return traverseTo ( ... pins ) ; } subscribe ( observer ? ) ; subscribe ( next ? , error ? , complete ? ) ; param observerOrNext param error param complete returns subscribe ( observerOrNext ? , error ? , complete ? ) { if ( error || complete ) return this . track ( this . observable . pipe ( map ( ( e ) => e . value ) ) . subscribe ( observerOrNext as ResolveCallback < any > , error , complete ) ) ; else return this . track ( this . observable . pipe ( map ( ( e ) => e . value ) ) . subscribe ( observerOrNext as any ) ) ; } }