import { MetaEntry, SelectorMixin } from '../types'; import { AsyncState, AsyncMode, AsyncHandler, AsyncOptions, AsyncActions } from './types'; import { Abortable } from './abortable'; /** * Options for creating an async selector mixin. */ export interface AsyncMixinOptions extends AsyncOptions { /** * Initial async state. Defaults to `async.fresh()`. */ initial?: AsyncState; /** * Name of store for the async state. Defaults to `async:${handler.name || "anonymous"}`. */ name?: string; /** * Metadata for the async state. * - Single meta: `meta: persist()` * - Multiple metas: `meta: meta.of(persist(), notPersisted.for("result"))` */ meta?: MetaEntry<"result"> | { metas: MetaEntry<"result">[]; }; } /** * Result tuple from async selector mixin: [state, actions] */ export type AsyncMixinResult = [ AsyncState, AsyncActions ]; /** * Create an async selector mixin for component-local async state. * Uses `scoped()` internally, so state is isolated per component and auto-disposed. * * @example * const submitMutation = async.mixin(async (ctx, data: FormData) => { * const res = await fetch('/api/submit', { * method: 'POST', * body: JSON.stringify(data), * signal: ctx.signal, * }); * return res.json(); * }); * * function ContactForm() { * const [state, { dispatch }] = useStore(({ mixin }) => mixin(submitMutation)); * return ; * } */ export declare function mixin(handler: AsyncHandler, options?: AsyncMixinOptions): SelectorMixin>; /** * Create an async selector mixin with stale mode. */ export declare function mixin(handler: AsyncHandler, options: AsyncMixinOptions & { initial: AsyncState; }): SelectorMixin>; /** * Create an async selector mixin with an Abortable (signal auto-injected). */ export declare function mixin(abortableFn: Abortable, options?: AsyncMixinOptions): SelectorMixin>; /** * Create an async selector mixin with an Abortable and stale mode. */ export declare function mixin(abortableFn: Abortable, options: AsyncMixinOptions & { initial: AsyncState; }): SelectorMixin>; //# sourceMappingURL=mixin.d.ts.map