UNPKG

entangle.ts

Version:

A declarative, event-driven framework for orchestrating business logic in TypeScript & Node.js applications.

30 lines (29 loc) 1.65 kB
import { ErrorHandler } from '../../errors/ErrorHandler'; import { Event } from '../../shared/types/Events.types'; import { Interaction, Target } from '../../shared/types/Interactions.types'; import { Callback, MethodKeys, ResolvableArgs } from '../../shared/types/Utils.types'; import { Superposition } from '../Superposition'; export declare class InteractionBuilder<TParticle extends object, TArgs extends unknown[], TMethodName extends MethodKeys<TParticle> | null = null> { private readonly parent; private readonly event; private readonly interaction; constructor(parent: Superposition, event: string, initialInteraction?: Partial<Interaction<TParticle, TArgs, any>>); use(target: Target<TParticle, TArgs>): this; /** * Specifies the method to be called on the target particle. * @param method The name of a method that exists on the target particle. * @returns A NEW, more specific, InteractionBuilder instance. */ call<TNewMethodName extends MethodKeys<TParticle>>(method: TNewMethodName): InteractionBuilder<TParticle, TArgs, TNewMethodName>; /** * Provides the arguments for the method specified in `.call()`. * The arguments are strongly typed based on the chosen method. */ with(...args: TMethodName extends MethodKeys<TParticle> ? ResolvableArgs<Parameters<Extract<TParticle[TMethodName], (...args: any[]) => unknown>>> : never): this; emit(event: Event): this; requirements(events: Event[]): this; once(): this; entanglement(entanglement: string): this; catch(errorHandler: ErrorHandler): this; then(callback?: Callback): Superposition; }