@rarible/action
Version:
Action is almost like async function, but actions can be divided into steps. It gives more control over action execution.
21 lines (20 loc) • 1.13 kB
TypeScript
import CallableInstance from "callable-instance";
import type { Action } from "./action.js";
import type { Execution } from "./execution.js";
type AB<Ctx, Id, In, Out> = ActionBuilder<Ctx, Id, In, Out>;
export declare abstract class ActionBuilder<Ctx, Id, In, Out> extends CallableInstance<[Ctx, In], Promise<Out>> {
protected constructor();
instanceMethod(ctx: Ctx, input: In): Promise<Out>;
start(ctx: Ctx, input: In): Execution<Id, Out>;
abstract build(ctx: Ctx): Action<Id, In, Out>;
before<NewIn>(map: (input: NewIn) => In | Promise<In>): AB<Ctx, Id, NewIn, Out>;
after<NewOut>(map: (input: Out) => NewOut | Promise<NewOut>): AB<Ctx, Id, In, NewOut>;
thenActionBuilder<NewId, NewOut>(ab: AB<Ctx, NewId, Out, NewOut>): AB<Ctx, NewId | Id, In, NewOut>;
static create<Ctx, Id, In, Out>(build: (ctx: Ctx) => Action<Id, In, Out>): SimpleActionBuilder<Ctx, Id, In, Out>;
}
declare class SimpleActionBuilder<Ctx, Id, In, Out> extends ActionBuilder<Ctx, Id, In, Out> {
private readonly f;
constructor(f: (ctx: Ctx) => Action<Id, In, Out>);
build(ctx: Ctx): Action<Id, In, Out>;
}
export {};