ui/async_slot.svelte.ts view source
Reactive container for a single async operation.
generics
T
voidE
stringstatus
type AsyncStatus
data
type T | undefined
error
type E | null
error_data
The raw caught value from the last failed run(), for programmatic inspection.
type unknown
initial
Convenience derived: status === 'initial'.
type boolean
loading
Convenience derived: status === 'pending'.
type boolean
succeeded
Convenience derived: status === 'success'.
type boolean
failed
Convenience derived: status === 'failure'.
type boolean
constructor
type new <T = void, E = string>(options?: AsyncSlotOptions<T, E>): AsyncSlot<T, E>
options
AsyncSlotOptions<T, E>{}run
Run an async operation. The callback receives an AbortSignal it
can forward to fetch / RPC clients that support cancellation; the
slot also discards superseded results internally even if the
callback ignores the signal.
Supersession rule: a second run() aborts the first's signal AND
silently drops its commit if it resolves anyway. So
back-to-back-to-back run() calls leave only the last call's
result in data.
Abort rule: a run() that throws because of its own signal (manual
abort(), external options.signal, OR supersession by another
run()) does NOT promote to 'failure'. Manual / external aborts
revert status to the previous resolved state ('initial' if no
run() has ever succeeded, 'success' otherwise). Supersession is
handled by the bail-on-mismatch check, leaving the second run's
'pending' standing.
type (fn: (signal: AbortSignal) => Promise<T>, options?: RunOptions): Promise<T | undefined>
fn
(signal: AbortSignal) => Promise<T>options
{}Promise<T | undefined>the resolved value on success; undefined on failure,
abort, or supersession
abort
Manually abort the in-flight run, if any. Reverts status
synchronously to the prior resolved state — 'initial' if no
run() (or set()) has ever succeeded on this slot, 'success'
otherwise. The aborted run's eventual resolution / rejection is
dropped without writing to state (the run's Promise resolves to
undefined).
type (reason?: unknown): void
reason?
unknownvoidset
Replace data directly and mark the slot 'success'. For
post-mutation hydration where the calling RPC already returned the
canonical row (parallels CellState.set_cell).
Aborts any in-flight run() first — without this, the in-flight
callback could resolve after set() and overwrite the explicit
value (the bail-on-mismatch check only fires when #controller
was rotated).
type (data: T): void
data
Tvoidreset
Reset to 'initial', clear data / error / error_data, and
abort any in-flight run. After reset() the slot looks like a
fresh instance with no initial option.
type (): void
void