Import
import { KeyedOptions } from "@typed/fx/Fx";Signatures
export interface KeyedOptions<A, B, C, E2, R2> {
readonly getKey: (a: A) => B;
readonly onValue: (ref: RefSubject.RefSubject<A>, key: B) => Fx<C, E2, R2 | Scope.Scope>;
readonly debounce?: Duration.Input;
}Why
The options put identity, per-identity work, and output coalescing beside one another so callers can choose collection behavior without exposing the keyed implementation’s maps, child Scopes, or diff patches.
Ownership and lifetime
The options object acquires nothing. {@link keyed} invokes onValue once per
admitted key. Its run fiber belongs to the outer parent Scope; the per-key
child Scope is supplied to that Fx for resources it explicitly registers.
Property: debounce
Delays and coalesces array emissions after keyed state changes.
Property: debounce: Why
Several child updates can describe one logical collection change. Debounce replaces the pending array emission so consumers receive the latest coherent ready prefix rather than every intermediate scheduling step.
Property: debounce: Ownership and lifetime
The delay fiber belongs to the outer keyed Scope. A later change interrupts
and replaces it; outer completion waits for the final scheduled emission and
interruption discards it. Omission uses a one-millisecond delay.
Property: getKey
Extracts the stable identity of an element.
Property: getKey: Why
A key lets value updates and moves reuse one existing child rather than interpreting array position as identity.
Property: getKey: Ownership and lifetime
The function is called synchronously while processing a source array. It acquires no resource; keys are retained only while their entries are live.
Property: onValue
Creates the Fx for one key from its live value RefSubject and stable key.
Property: onValue: Why
Passing a RefSubject separates identity from the current value: later
values with the same key update the existing child instead of recreating it.
Property: onValue: Ownership and lifetime
keyed calls this once when a key is added and forks its run fiber in the
outer parent Scope. It provides a per-key child Scope to the run, so
resources registered through that service close when the key is removed.
Closing the child Scope does not by itself interrupt an arbitrary returned
Fx run fiber; resourceful work must honor the supplied Scope. Failures and
services remain on the returned keyed Fx.
Examples
import { Fx } from "@typed/fx"
interface Row { readonly id: string; readonly value: number }
const options: Fx.KeyedOptions<Row, string, number, never, never> = {
getKey: (row) => row.id,
onValue: (row) => Fx.map(row, ({ value }) => value)
}Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.