Skip to content

Vue Composables

Complete API reference for @asyncflowstate/vue.

useFlow

Primary composable for managing async actions with reactive Refs in Vue 3.

ts
function useFlow<TInput, TOutput>(
  action: (...args: TInput[]) => Promise<TOutput>,
  options?: FlowOptions<TInput, TOutput>,
): UseFlowResult<TInput, TOutput>;

Return Value (Reactive Refs)

PropertyTypeDescription
statusRef<string>Current flow status
loadingRef<boolean>true if action is currently running
dataRef<T | null>Last successful execution result
errorRef<Error | null>Last execution error
execute(...args) => Promise<T>Trigger action execution
reset() => voidReset state to idle
button() => objectGenerates v-bind props for buttons
form(opts) => objectGenerates v-bind props for forms
fieldErrorsReactive<Record>Live validation errors
executionCountRef<number>Total completion counter

provideFlowConfig

Sets global configuration for all descendants using Vue's provide/inject.

ts
import { provideFlowConfig } from "@asyncflowstate/vue";

provideFlowConfig({
  loading: { minDuration: 400 },
  retry: { maxAttempts: 3 },
});

useFlowSequence

Executes a sequence of steps where each step depends on the last.

ts
const sequence = useFlowSequence(steps);
// sequence.loading
// sequence.currentStep
// await sequence.execute(args)

useFlowParallel

Aggregates multiple flows into a single loading/data state.

ts
const parallel = useFlowParallel([flow1, flow2]);
// parallel.loading
// parallel.data (array)

Built with by AsyncFlowState Contributors
Open Source · MIT License