import { tap } from 'rxjs/operators' ; import { Emission } from '../shared/emission' ; import { Bindable } from '../shared/bindable' ; import { ContextType } from '../shared/types' ; import { Pipe } from './pipe' ; export type SinkFunc = ( value : any , context : ContextType ) => void ; /**
 *
 * Represents [sink](https://connective.dev/docs/sink) pins.
 *
 */ export class Sink extends Pipe implements Bindable { private _bound = false ; constructor ( readonly func = ( ) => { } ) { super ( [ tap ( ( emission ) => func ( emission . value , emission . context ) ) ] ) ; } returns public get bound ( ) { return this . _bound ; } /**
     *
     * Binds this sink if it is not already bound. Binding
     * Basically ensures that the pin is subscribed to and that its side-effect
     * will be enacted.
     *
     */ bind ( ) { if ( ! this . _bound ) { this . _bound = true ; this . track ( this . subscribe ( ) ) ; } return this ; } } param func export function sink ( func ? ) { return new Sink ( func ) ; } export default sink ;