Skip to content

useStoreAsyncOperations

useStoreAsyncOperations<TCode>(options): object

Defined in: hooks/useStoreAsyncOperations.ts:17

Composable for handling async operations in stores — consistent loading states, error normalization via an injected ErrorCodeAdapter, and operation execution. Generalized from the original app’s hook, which hardcoded a NestJS-shaped ApiError/error-code enum directly.

TCode extends string

UseStoreAsyncOperationsOptions<TCode>

object

error: ApiError<TCode> | null

executeOperation: <T>(operation, opts) => Promise<T | undefined>

T

() => Promise<T>

boolean

Promise<T | undefined>

fetchAllQuery: (newQuery) => Record<string, unknown>

PaginationQuery

Record<string, unknown>

handleApiError: (err, throwError) => void

unknown

boolean = true

void

loading: boolean

prepare: () => void

void

resetState: () => void

void

withAsyncOperation: <TArgs, TReturn>(operation, opts) => (…args) => Promise<TReturn | undefined>

TArgs extends unknown[]

TReturn

(…args) => Promise<TReturn>

boolean

(…args) => Promise<TReturn | undefined>