@askrjs/askr/resources
Exports from the declarations published in @askrjs/askr. Signatures reflect the published artifact.
Exports
This entrypoint publishes 20 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.
ActivityPredicatetype
ActivityPredicate: () => booleanA gating condition for lifecycle primitives like {@link timer}; `true` means active.
capturetype
capture: <T>(fn: () => T) => () => TCapture the result of a synchronous expression at call time and return a thunk that returns the captured value later. This is a low-level helper for cases where async continuations need to observe a snapshot of values at the moment scheduling occurred. Usage (public API): const snapshot = capture(() => someState()); Promise.resolve().then(() => { use(snapshot()); });
documentVisibletype
documentVisible: () => ActivityPredicate{@link ActivityPredicate} that is true while the document is visible.
getSignaltype
getSignal: () => AbortSignalGet the abort signal for the current component. The signal is guaranteed to be aborted when: - Component unmounts - Navigation occurs (different route) - Parent is destroyed
ListenerTargettype
ListenerTarget: EventTarget | (() => EventTarget | null | undefined)An event target, or a function resolving one, accepted by {@link on}.
ontype
on: (target: ListenerTarget, event: string, handler: EventListener, options?: ListenerOptions) => voidAttach an owned event listener to `target` for the current component's lifetime.
onRouteChangetype
onRouteChange: (fn: (current: RouteSnapshot, previous: RouteSnapshot | null) => RouteChangeCleanup, options?: RouteChangeOptions) => voidRegister a callback to run whenever the active route changes, with optional cleanup.
resourcetype
resource: <T, const TDeps extends readonly unknown[]>(fn: (opts: { signal: AbortSignal; }) => PromiseLike<T> | T, deps: TDeps) => ResourceResult<T>Creates a render-scoped async resource with cancellation and refresh; SSR has special data rules.
ResourceResulttype
ResourceResult: anyReactive result of a {@link resource}: current value, loading state, and controls.
value- value: T | null;
pending- pending: boolean;
error- error: Error | null;
refresh- refresh(): void;
routeActivetype
routeActive: (pathOrPaths: string | readonly string[]) => ActivityPredicate{@link ActivityPredicate} that is true while the current route matches `pathOrPaths`.
RouteChangeCleanuptype
RouteChangeCleanup: void | (() => void)Optional cleanup returned by an {@link onRouteChange} callback, run before the next change.
RouteChangeOptionstype
RouteChangeOptions: anyOptions for {@link onRouteChange}.
immediate- immediate?: boolean;
streamtype
stream: <T>(source: StreamSource<T>, options?: StreamOptions<T>) => StreamResult<T>Subscribe to a streaming data source for the current component's lifetime, with auto reconnect/cleanup.
StreamOptionstype
StreamOptions: anyOptions for {@link stream}.
deps- deps?: readonly unknown[];
initialValue- initialValue?: T;
StreamResulttype
StreamResult: anyReactive result of a {@link stream}: current value, connection status, and controls.
value- value: T | null;
status- status: StreamStatus;
pending- pending: boolean;
stale- stale: boolean;
error- error: Error | null;
restart- restart(): void;
close- close(): void;
StreamStatustype
StreamStatus: 'connecting' | 'connected' | 'reconnecting' | 'closed' | 'error'Connection status of a {@link stream}.
tasktype
task: (fn: () => void | (() => void) | PromiseLike<void | (() => void)>) => voidRuns an owned task after commit.
timertype
timer: (intervalMs: number, fn: () => void, options?: TimerOptions) => voidRun `fn` on an owned interval for the current component's lifetime, optionally gated by `options.when`.
TimerOptionstype
TimerOptions: anyOptions for {@link timer}.
when- when?: ActivityPredicate | readonly ActivityPredicate[];
windowFocusedtype
windowFocused: () => ActivityPredicate{@link ActivityPredicate} that is true while the window has focus.