resolveUseCancelablePromisesStatus()
Home > @gooddata/sdk-ui > resolveUseCancelablePromisesStatus
resolveUseCancelablePromisesStatus() function
Resolve status of multiple useCancelablePromise() hooks.
Signature:
export declare function resolveUseCancelablePromisesStatus(cancelablePromisesStates: UseCancelablePromiseState<unknown, unknown>[], options?: {
strategy?: "serial" | "parallel";
}): UseCancelablePromiseStatus;
Parameters
Parameter | Type | Description |
---|---|---|
cancelablePromisesStates | UseCancelablePromiseState<unknown, unknown>[] | |
options | { strategy?: "serial" | "parallel"; } | (Optional) specify options for resolving the status |
Returns:
resolved status
Remarks
This is useful for useCancelablePromise composition - when you want to wrap multiple useCancelablePromise hooks in another hook, and keep the return value shape of the hook same as for useCancelablePromise.
You can choose between 2 strategies to resolve the status (default strategy is "serial"): - serial: Short-circuits to the first pending/loading/error status, and returns the last status only when all previous statuses are "success". - parallel: Is resolved to the status which has the highest priority. Priority of the statuses has the following order (from highest to lowest): pending, loading, error, success. Examples: - ["pending", "loading"] will be resolved to "pending" - ["loading", "error"] will be resolved to "loading" - ["error", "success"] will be resolved to "error" - ["success", "success"] will be resolved to "success"