Effection Logo

interface Api

thefrontside/effection

interface Api<A>

A set of methods and values that can be decorated on a per-scope basis. Apis are ideal for situations that require context sensitivity such as dependency injection, test mocking, and instrumentation.

Type Parameters

A core shape of the Api

Properties

operations: [K in keyof A]: A[K] extends Operation<unknown> ? A[K] : A[K] extends (...args: ) => ? TReturn extends Operation<unknown> ? A[K] : (...args: TArgs) => Operation<TReturn> : Operation<A[K]>

Every member of A "lifted" into an operation that invokes that member on the current {Scope}

around: (middlewares: Partial<Around<A>>, optionsoptional: {}) => Operation<void>

Enhance an Api within this scope by surrounding it with middleware.

invoke: <K in keyof A>(scope: Scope, key: K, args: A[K] extends (...args: any) => unknown ? Parameters<A[K]> : []) => A[K] extends (...args: any) => unknown ? ReturnType<A[K]> : A[K]

Call an API as it exists on scope.

See