@xylabs/sdk-react
    Preparing search index...

    Variable useAtomicPromiseConst

    useAtomicPromise: <TResult>(
        name: string,
        promise: () => Promise<TResult | undefined>,
        dependencies: DependencyList,
        config?: UsePromiseConfig<TResult>,
    ) => [TResult | undefined, Error | undefined, UsePromiseState | undefined]

    A custom hook that ensures a promise is executed atomically, using a mutex to prevent concurrent executions.

    Type Declaration

      • <TResult>(
            name: string,
            promise: () => Promise<TResult | undefined>,
            dependencies: DependencyList,
            config?: UsePromiseConfig<TResult>,
        ): [TResult | undefined, Error | undefined, UsePromiseState | undefined]
      • Type Parameters

        • TResult

          The type of the result that the promise resolves to.

        Parameters

        • name: string

          A unique name for the mutex to ensure atomic execution.

        • promise: () => Promise<TResult | undefined>

          A function that returns the promise to be executed.

        • dependencies: DependencyList

          An array of dependencies that will trigger the promise execution when changed.

        • Optionalconfig: UsePromiseConfig<TResult>

          Optional configuration for the promise execution.

        Returns [TResult | undefined, Error | undefined, UsePromiseState | undefined]

        An array containing the result of the promise, any error that occurred, and the state of the promise.