• Suspends rendering until an executor satisfies a predicate.

    Type Parameters

    • Value

      The value stored by the executor.

    Parameters

    • executor: Executor<Value>

      The executors to get value of.

    • predicate: ((executor: Executor<any>) => boolean) = isNotFulfilled

      The predicate which a pending executor must conform to suspend the rendering process. By default, only non-fulfilled executors are awaited.

        • (executor): boolean
        • Parameters

          Returns boolean

    Returns Executor<Value>

    The executor value.

    // Suspend if executor is pending or get the current value
    const value = useExecutorSuspense(useExecutor('test', heavyTask)).get();
    const cheeseExecutor = useExecutor('cheese', buyCheeseTask);
    const beadExecutor = useExecutor('bread', bakeBreadTask);

    // Executors run in parallel and rendering is suspended until both of them are settled
    useExecutorSuspense(cheeseExecutor);
    useExecutorSuspense(breadExecutor);