@rarible/action
Version:
Action is almost like async function, but actions can be divided into steps. It gives more control over action execution.
16 lines (15 loc) • 980 B
TypeScript
import CallableInstance from "callable-instance";
import type { Step } from "./execution.js";
import { Execution } from "./execution.js";
export declare class Action<Id, In, Out> extends CallableInstance<[In], Promise<Out>> {
private readonly steps;
private constructor();
instanceMethod(input: In): Promise<Out>;
thenStep<NewId, NewOut>(step: Step<NewId, Out, NewOut>): Action<Id | NewId, In, NewOut>;
thenAction<NewId, NewOut>(action: Action<NewId, Out, NewOut>): Action<Id | NewId, In, NewOut>;
around<NewIn, NewOut>(mapIn: (input: NewIn) => In | Promise<In>, mapOut: (input: Out, initialIn: NewIn) => NewOut | Promise<NewOut>): Action<Id, NewIn, NewOut>;
before<NewIn>(map: (input: NewIn) => In | Promise<In>): Action<Id, NewIn, Out>;
after<NewOut>(map: (input: Out) => NewOut | Promise<NewOut>): Action<Id, In, NewOut>;
start(input: In): Execution<Id, Out>;
static create<Id, T, In = void>(step: Step<Id, In, T>): Action<Id, In, T>;
}