React Executor - v0.0.28
    Preparing search index...

    Function useExecutorSuspense

    • Suspends rendering until an executor satisfies a predicate.

      Type Parameters

      • Value

        The value stored by the executor.

      Parameters

      • executor: Executor<Value>

        The executor to suspend on.

      • shouldSuspend: (executor: Executor) => boolean = isNotFulfilled

        A predicate called on a pending executor. If it returns true, rendering is suspended until the executor settles. If it returns false, rendering continues immediately with whatever state the executor currently holds. Only called when the executor is pending — non-pending executors never trigger suspension regardless of this predicate. Defaults to suspending whenever the executor is pending and not yet fulfilled.

      Returns Executor<Value>

      The executor, for chaining with get or getOrDefault.

      // Suspend while the executor is pending, then get the settled value
      const value = useExecutorSuspense(useExecutor('test', heavyTask)).get();
      const cheeseExecutor = useExecutor('cheese', buyCheeseTask);
      const breadExecutor = useExecutor('bread', bakeBreadTask);

      // Executors run in parallel; rendering suspends until both are settled
      useExecutorSuspense(cheeseExecutor);
      useExecutorSuspense(breadExecutor);
      // Only suspend if the executor has never been fulfilled before (allow stale values through)
      useExecutorSuspense(executor, executor => !executor.isSettled);