@connectv/core
Version:
agent-based reactive programming library for typescript/javascript
80 lines (79 loc) • 2.18 kB
TypeScript
import { Subject, Observable } from 'rxjs';
import { ContextType } from '../shared/types';
import { Emission } from '../shared/emission';
import { PinLike } from './pin-like';
import { Connectible } from './connectible';
/**
*
* Represents [source](https://connective.dev/docs/source) pins.
*
*/
export declare class Source extends Connectible {
private _subject;
constructor(_subject?: Subject<Emission>);
/**
*
* This source will send given value, perhaps with given context.
* Will create a new [emission](https://connective.dev/docs/emission) object.
*
* @param value the value to send
* @param context the emission context
*
*/
send(value?: any, context?: ContextType): void;
/**
*
* Will emit the given emission object.
*
* @param emission
*
*/
emit(emission: Emission): void;
/**
*
* @note this sends a complete notification through-out the flow.
* Pins that are merely reliant on this source will also be unusable
* afterwards.
*
*/
clear(): this;
/**
*
* Determines if any pin is connected to this pin.
*
*/
protected isConnected(): boolean;
/**
*
* Resolves the underlying observable of this pin by subscribing the
* subject of this pin to all inbound pins.
*
* @param inbound
*
*/
protected resolve(inbound: PinLike[]): Subject<Emission>;
/**
*
* Determines whether this pin is locked. A source is never locked.
*
*/
protected isLocked(): boolean;
/**
*
* Determines whether should resolve the underlying observable.
*
* @param inbound
* @param observable
*
*/
protected shouldResolve(inbound: PinLike[], observable: Observable<any> | undefined): boolean;
}
/**
*
* 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 declare function source(sub?: Subject<Emission>): Source;
export default source;