PredictionScheduler decides when
to spend it using delay, foreground activity, browser conditions, and idle opportunities.
Schedule background work
ScheduledPrediction remains pending until its gates pass. started resolves to a
PredictionHandle, or null if cancelled first.
Scheduling gates
Four conditions shape the start time:delayMsis a soft delay before the candidate becomes eligible.- Foreground activity blocks ordinary background starts.
idle: truerequests an idle opportunity after the other gates pass.- The environment gate can block every start.
idleTimeoutMs only limits the idle wait.
maxDeferMs can bypass foreground and idle waits after a ceiling, but never the environment gate.
Omit it when foreground activity may defer warmup indefinitely.
When foreground activity transitions from a positive count back to zero, soft delays restart. When
the environment becomes allowed again, both soft delays and maximum-defer clocks restart.
Foreground activity
Feed the host’s active foreground request count into the scheduler:allowDuringForeground: true can exempt one item, though
direct intent usually expresses the reason more clearly.
Direct intent
ScheduledPrediction.startNow() treats pointer down or focus as direct intent, bypassing delay, idle,
and foreground waits while respecting the environment gate.
IntentPrefetchController provides a framework-neutral delayed signal for hover-like intent and an
immediate path for pointer, focus, touch, or click:
runNow() cancels the delay; errors go to onError without
affecting the committed interaction.
Cancel obsolete work
Cancel a key when invalidation, tenant changes, or route policy makes it obsolete:started with null. Once work has entered the coordinator, the
scheduler forwards cancellation to its prediction handle and aborts the loader.
Calling dispose() cancels all pending schedules. It also disposes the coordinator when the
scheduler created that coordinator itself. If you inject options.coordinator, its lifetime remains
the caller’s responsibility.
Continue
- Browser runtime and navigation metrics details environment decisions, idle fallback, and timing evidence.
- Client API reference lists scheduler and intent signatures.