FetchMixin
Auto-generated from the @jbrowse/mobx-state-tree model in the source. See the developer guide for concepts. Built into JBrowse core. View source.
Cancel-safe fetch lifecycle for any display that loads data over RPC: abort
rotation, staleness, error capture and status reporting. Consumers use
runFetch, cancelFetch, isLoading, error, statusMessage and
fetchGeneration. Every fetch foundation composes it: the per-region family
directly, the global and comparative families through KeyedFetchMixin.
Volatiles
| Member | Description |
|---|---|
activeSignalAbortSignal | undefined |
signal of the in-flight fetch, or undefined when idle |
fetchGenerationnumber |
Bumps when a current fetch ends (never for a superseded one) and on cancelFetch, not on cancelFetchByUser, which is what makes a user cancel durable. Fetch autoruns read it to re-evaluate. |
reloadCounternumber |
Bumped by reload() and read unconditionally by every fetch autorun, so a retry re-runs the body even when no other input moved, as after an error. makeRetryContractCheck reports a bump that fetches nothing: a dead Retry button. |
statusWindowStatusWindow |
The display's status field's only writer: one throttle window, one slot per concurrent operation, so parallel per-region fetches thin to one stream and one operation cannot end another's label (ADR-081). |
errorunknown |
last non-abort fetch error, or undefined |
statusMessagestring | undefined |
work-in-progress status string |
statusProgressnumber | undefined |
determinate progress fraction [0,1] for the current status, or undefined when the in-flight phase is indeterminate |
fetchCanceledboolean |
True after the user cancels a load from the loading overlay. Unlike cancelFetch it does not retrigger the fetch autoruns, so the load stays stopped until reload or a viewport change; any new fetch clears it. |
fetchRotation{ begin(): ActiveFetch; cancel: () => void; dispose(): void; } |
The latest-wins machine runFetch wraps: abort rotation, the isCurrent guard, the status slot and the supersede-versus-end rule (ADR-080, ADR-081). A second concurrent fetch on the same display holds its own rotation (ADR-054 §1, which ADR-105 keeps). It takes a slot on this display's statusWindow rather than opening a second window. |
Getters
| Member | Description |
|---|---|
isLoadingboolean |
true while a fetch is active |
isLoadingOrCanceledboolean |
isLoading or a user-canceled load: neither has a frame on screen for a hover to describe. Not a phase input, since computeActivityPhase tells loading from canceled. |
fetchInertboolean |
Overridable hook (default false): the states where this display deliberately fetches nothing, such as sequence past base resolution or LD with the triangle off. Three readers depend on it: the phase (computeActivityPhase), which would otherwise scrim the placeholder; the SVG export (computeSvgReady), whose unbounded wait would hang the view's export; and the retry contract check, which would report a dead Retry. ADR-082.Override this rather than displayPhase, which would restate the whole loading condition and miss any term added to it later. |
awaitingPrerequisiteboolean |
Overridable hook (default false), read only by the retry contract check: this run declined because a prerequisite fetch in another autorun has not landed, and its arrival wakes this one. It defers the retry verdict to that run rather than waiving it, so it must be strictly narrower than the gate it explains; one restating the gate's negation exempts the display from the check. HiC's contacts (waiting on CoreGetInfo) and LinearVariantDisplay (waiting on sourcesBase) set it. For a display not fetching at all, use fetchInert. |
awaitingDependentDataboolean |
Overridable hook (default false), read by computeActivityPhase and foundationSvgReady: a load beyond the primary fetch has not landed for the first time, so the frame is still missing something. Multi-way synteny sets it until its lane genes and links first arrive; TreeSidebarMixin sets it while a declared clustering run is due. Unlike dataSuperseded, it holds the scrim and export on the first landing only. |
fetchHeldboolean |
Overridable hook (default fetchCanceled), read by the viewport-change lapse both LGV families install: a state that holds the fetch off until the view moves. The per-region family adds an error, which its plan skips on; the global skeleton is not held by an error, since a move that changes its key refetches anyway. |
settingsFetchInputsunknown |
The settings axis every fetch family invalidates on: rpcProps() and the adapter config, as one value compared structurally. The per-region family stamps it on each region, the keyed families fold it into currentFetchKey, and the byte gate measures under it. |
Actions
| Member | Description |
|---|---|
setError(error?: unknown) => void |
|
setStatusMessage(status?: RpcStatus) => void |
Unthrottled, so a phase label written by hand always lands; the RPC stream is thinned by the slots statusWindow hands out. |
stopActiveFetch() => void |
Abort the in-flight fetch, if any, and retire its status slot: the shared preamble of both cancel paths. It never resets the window, which would drop a sibling operation's queued status write on every clearAllRpcData (ADR-081); only teardown resets it. |
openStatusStream(isCurrent: () => boolean) => StatusStream |
Open a slot on the display's status field for an operation outside any fetch, such as the tree sidebar's clustering run: a throttled RPC statusCallback and the clear that retires it. isCurrent is required because a live node is not enough: a superseded run's late status must not repaint the overlay of the run that replaced it. |
cancelFetch() => void |
Cancel any in-flight fetch, clear a user cancel and bump fetchGeneration, so the fetch autoruns re-fetch. The internal reset clearAllRpcData runs. |
cancelFetchByUser() => void |
The loading overlay's Cancel: stop the fetch and set the durable fetchCanceled, without bumping fetchGeneration, so nothing restarts the load until reload or a viewport change. |
reload() => void |
The display's half of the retry contract (DISPLAYCHROME.md): clear the error, clear a user cancel at once so the overlay flips to loading, and bump reloadCounter. Each foundation chains this and adds the invalidation its freshness gate needs. An override that neither chains nor bumps the counter turns the retry check off; reloadReachesCounter.test.ts reads every reload() in the tree. |
beforeDestroy() => void |
Abort an in-flight fetch on teardown, so a closed track stops downloading, and reset the status window, whose trailing write still holds a timer after the last fetch ends. |
beginFetch(signal: AbortSignal) => void |
The onBegin half of a fetch's bookkeeping: publish the signal (isLoading) and clear a user cancel, the one clear point every retrigger path passes through. |
endFetch(current: boolean) => void |
The onEnd half, an action because runFetchOnce's finally runs outside the flow. A superseded fetch writes nothing, or it would clear the loading flag of the fetch that replaced it. |
lapseHeldFetch() => void |
The viewport-change lapse of fetchHeld: clear a user cancel and bump fetchGeneration, leaving held data and the drawn canvas alone. The per-region family chains it to clear its error too. |
runFetch(work: (ctx: FetchContext) => Promise<void>) => Promise<void> |
Run a cancel-safe fetch, superseding any prior one. work gets a FetchContext with the signal to forward to the RPC and isStale() to skip commits once the user has moved on. The sequence is the shared runFetchOnce; this adds the observable bookkeeping and the flow, which runs work's synchronous prefix untracked. |
Related links
- Developer guide: Data fetching pipeline