Reference
@reckona/mreact-reactive-core
31 public exports.
Function
Functionbatch
function batch<T>(fn: (): T): TGroups reactive writes and flushes dependents after the callback returns.FunctionbatchAsyncfunction batchAsync<T>(fn: (): T | Promise<T>): Promise<T>Groups reactive writes across an async callback and flushes after it settles.Functioncellfunction cell<T>(initial: T): Cell<T>Functioncomputedfunction computed<T>(fn: (): T, options?: ComputedOptions<T> | ComputedEquality<T>): ReadonlyCell<T>Creates a lazily evaluated reactive value derived from other cells.FunctioncreateCleanupScopefunction createCleanupScope(): CleanupScopeCreates an idempotent LIFO cleanup owner.FunctioncreateEventResourcefunction createEventResource<TKey, TEvent>(subscribe: (key: TKey, emit: (event: TEvent): void): (): void, options: { capacity: number }): EventResource<TKey, TEvent>Creates a bounded event stream. Overflow evicts oldest events and reports their count.FunctioncreateResourcefunction createResource<TKey, TValue>(subscribe: (key: TKey, emit: (value: TValue): void): (): void): Resource<TKey, TValue>Creates an opt-in, latest-value resource. Keys use Map identity and equality.Functioneffectfunction effect(fn: (): void | (): void): (): voidRuns a reactive side effect and returns a disposer.FunctioninstallRequestStateStoragefunction installRequestStateStorage(storage: RequestStateStorage | undefined): voidInstalls request-local storage. Server adapters install this automatically.FunctionrequestStatefunction requestState<T>(initialize: (): T): (): TDeclares lazily initialized state: one value per server request, or one value in the browser. Create mutable values and their computed dependencies inside the initializer. Initializer resources belong to the request, independently of the calling component. Server reads outside a request scope throw instead of sharing process-wide state.FunctionrunDetachedfunction runDetached<T>(run: (): T): TRuns a synchronous callback without an implicit cleanup owner; the caller owns resource disposal.FunctionrunWithCleanupScopefunction runWithCleanupScope<T>(scope: CleanupScope, run: (): T): TRuns a synchronous callback with a public cleanup scope as its dynamic owner.FunctionrunWithRequestStatefunction runWithRequestState<T>(callback: (): T): TRuns work in a fresh request state scope using installed AsyncLocalStorage. Disposes initializer resources when the callback returns or its promise settles. Await all work, including stream consumption, inside the callback.Functionselectorfunction selector<TValue, TKey>(source: ReadonlyCell<TValue>, options?: { equals?: SelectorEquality<TValue, TKey> }): Selector<TValue, TKey>Creates keyed boolean cells that update only for the previous and next selected keys.Functionuntrackfunction untrack<T>(fn: (): T): TRuns a callback without recording reactive dependencies.Interface
InterfaceCell
interface CellMutable reactive value that notifies dependents when changed.InterfaceCleanupScopeinterface CleanupScopeOwns cleanup callbacks for DOM-independent resources.InterfaceComputedOptionsinterface ComputedOptionsOptions for creating a computed reactive value.InterfaceEventResourceinterface EventResourceA factory that shares one upstream event subscription per active key.InterfaceEventResourceBatchinterface EventResourceBatchEvents and loss since the last drain of one event observer.InterfaceEventResourceLeaseinterface EventResourceLeaseAn independent bounded queue attached to a keyed event subscription.InterfaceEventResourceStateinterface EventResourceStateQueue occupancy and loss since the last drain of one event observer.InterfaceReadonlyCellinterface ReadonlyCellReactive value that can be read and tracked as a dependency.InterfaceRequestStateStorageinterface RequestStateStorageAsyncLocalStorage-compatible storage for request state integrations.InterfaceResourceinterface ResourceA factory that shares one external subscription for each active key.InterfaceResourceLeaseinterface ResourceLeaseA single observer of a keyed external subscription.InterfaceSelectorinterface SelectorA keyed boolean selector with an explicit disposer for the source subscription.Type Alias
Type AliasComputedEquality
type ComputedEquality = (previous: T, next: T): booleanEquality function used to decide whether a computed value changed.Type AliasRequestStateScopetype RequestStateScope = Map<object, unknown>Storage owned by one server request. Values are initialized lazily.Type AliasResourceStatetype ResourceState = { status: "pending" } | { status: "ready"; value: T }The latest value from a continuous external subscription, or its initial state.Type AliasSelectorEqualitytype SelectorEquality = (value: TValue, key: TKey): booleanEquality function used by selector keys.