@connectv/core
Version:
agent-based reactive programming library for typescript/javascript
90 lines (89 loc) • 3.15 kB
TypeScript
import { Observable, PartialObserver, Subscription } from 'rxjs';
import { Emission } from '../shared/emission';
import { Tracker } from '../shared/tracker';
import { PinLike } from './pin-like';
import { Group } from './group';
/**
*
* Represents a partial reactive flow, with some entry pins going into it
* and some exit pins coming out of it.
*
*/
export declare 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;
/**
*
* Connects all given pins to all of its entry pins
*
* @param pins
* @returns a [group](https://connective.dev/docs/group) of the given pins. If any `PartialFlow`
* was among the given pins, its entry pins will be added to the group.
*
*/
from(...pins: PinLike[]): PinLike;
/**
*
* Connects all of its exit pins to given pins
*
* @param pins
* @returns a [group](https://connective.dev/docs/group) of the given pins. If any `PartialFlow`
* was among the given pins, its exit pins added to the group.
*
*/
to(...pins: PinLike[]): PinLike;
/**
*
* Connects all given pins serially to its entry pins
*
* @param pins
* @returns a [group](https://connective.dev/docs/group) of the given pins. If any `PartialFlow`
* was among the given pins, its entry pins will be added to the group.
*
*/
serialFrom(...pins: PinLike[]): PinLike;
/**
*
* Connects all of its exit pins to given pins
*
* @param pins
* @returns a [group](https://connective.dev/docs/group) of the given pins. If any `PartialFlow`
* was among the given pins, its exit pins added to the group.
*
*/
serialTo(...pins: PinLike[]): PinLike;
get observable(): Observable<Emission>;
subscribe(observer?: PartialObserver<any>): Subscription;
subscribe(next?: (value: any) => void, error?: (error: any) => void, complete?: () => void): Subscription;
}
export declare type PartialFlowFactory = () => [Group | PinLike[], Group | PinLike[]];
declare class InlineFlow extends PartialFlow {
readonly factory: PartialFlowFactory;
entries: Group;
exits: Group;
constructor(factory: PartialFlowFactory);
}
/**
*
* Creates a partial flow, using the given factory function. The factory function
* should return either a [`group`](https://connective.dev/docs/group) or an array
* of [pins](https://connective.dev/docs/pin) for inputs, and a group or an array of pins
* for outputs, in array format itself (first object being the inputs, second the outputs).
*
* @param factory
*
*/
export declare function partialFlow(factory: PartialFlowFactory): InlineFlow;
export default partialFlow;