import { Subject , Observable } from 'rxjs' ; import { ContextType } from '../shared/types' ; import emission , { Emission } from '../shared/emission' ; import { PinLike } from './pin-like' ; import { Connectible } from './connectible' ; /**
 *
 * Represents [source](https://connective.dev/docs/source) pins.
 *
 */ export class Source extends Connectible { constructor ( private _subject = new Subject < Emission > ( ) ) { super ( ) ; } param value param context public send ( value ? , context ? ) { this . emit ( emission ( value , context ) ) ; } param emission public emit ( emission ) { this . _subject . next ( emission ) ; } note clear ( ) { this . _subject . complete ( ) ; this . _subject = new Subject < any > ( ) ; return super . clear ( ) ; } /**
     *
     * Determines if any pin is connected to this pin.
     *
     */ protected isConnected ( ) { return this . tracking || super . isConnected ( ) ; } param inbound protected resolve ( inbound ) { inbound . forEach ( pin => { this . track ( pin . observable . subscribe ( this . _subject ) ) ; } ) ; inbound . length = 0 ; return this . _subject ; } /**
     *
     * Determines whether this pin is locked. A source is never locked.
     *
     */ protected isLocked ( ) { return false ; } param inbound param observable protected shouldResolve ( inbound , observable ) { return inbound . length > 0 || ! observable ; } } /**
 *
 * Creates a [source](https://connective.dev/docs/source) pin.
 * A source pin can be used as the starting point of a reactive flow.
 * [Checkout the docs](https://connective.dev/docs/source) for examples and further information.
 *
 */ export function source ( sub ? ) { return new Source ( sub ) ; } export default source ;