@askrjs/askr/resources
Exports from the declarations published in @askrjs/askr. Signatures reflect the published artifact.
Exports
This entrypoint publishes 21 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.
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.
resourcetype
resource: { <TSource, T>(source: () => TSource, load: (value: TSource, opts: { signal: AbortSignal; }) => PromiseLike<T> | T): ResourceResult<T>; <T, const TDeps extends readonly unknown[] = readonly unknown[]>(fn: (opts: { signal: AbortSignal; }) => PromiseLike<T> | T, deps: TDeps): ResourceResult<T>; <T>(fn: (opts: { signal: AbortSignal; }) => PromiseLike<T> | T): ResourceResult<T>; }Create a source-driven resource whose loader receives the latest source value. 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.
streamtype
stream: { <TSource, T>(source: () => TSource, connect: (value: TSource, context: { signal: AbortSignal; }) => AsyncIterable<T> | PromiseLike<AsyncIterable<T>>, options?: Omit<StreamOptions<T>, "deps">): StreamResult<T>; <T>(source: StreamSource<T>, options?: StreamOptions<T>): StreamResult<T>; }Connect a stream from an input read during a positional component render. 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[];
watchtype
watch: { <TValue>(source: WatchSource<TValue>, callback: WatchCallback<TValue>): void; <const TSources extends readonly WatchSource<unknown>[]>(sources: TSources extends WatchSource<unknown> ? never : TSources, callback: WatchCallback<WatchValues<TSources>>): void; }Observe one readable source after commit and whenever its value changes. Observe an ordered tuple of readable sources after commit and whenever an entry changes.
WatchCallbacktype
WatchCallback: (
value: TValue,
context: WatchContext<TValue>
) => void | (() => void) | PromiseLike<void>Owned side-effect callback invoked by {@link watch}.
WatchContexttype
WatchContext: anyPost-commit generation details supplied to a {@link watch} callback.
initial- readonly initial: boolean;
previous- readonly previous: TValue | undefined;
signal- readonly signal: AbortSignal;
WatchSourcetype
WatchSource: () => TA callable reactive source accepted by {@link watch}.
WatchValuestype
WatchValues: {
-readonly [TIndex in keyof TSources]: ReturnType<TSources[TIndex]>;
}Values inferred from an ordered tuple of {@link WatchSource} accessors.
windowFocusedtype
windowFocused: () => ActivityPredicate{@link ActivityPredicate} that is true while the window has focus.