function / @typed/ui/index

Collection.register

Upserts an item immediately and installs a finalizer in the Scope that runs this Effect; the finalizer removes only that exact registration.

Learn this UI primitive →

Package version
1.0.0-beta.7
Category
Item registration
Since
1.0.0
Member of
Collection

Import

import { Collection } from "@typed/ui/index";

Access Collection.register through the imported Collection export. Its declaration below describes the member.

This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.

Signatures

export declare function register<Value, Element extends object, E, R>(collection: RefSubject.RefSubject<State<Value, Element>, E, R>, item: Item<Value, Element>): Effect.Effect<void, E, R | Scope.Scope>;

Why

The operation exposes Collection’s transition directly so callers can compose it in Effect programs and native event handlers.

Ownership and lifetime

Registration is owned by the Scope in which the registration Effect runs. Closing that Scope removes the exact registered item; creating the collection or state does not own this cleanup.

Example

Import with import { register } from "@typed/ui/Collection"; Extend the Collection.makeState runnable setup. Inside the linked Effect program invoke yield* register(collection, { id: "save", value: "save" }), then read the collection to observe the inserted item.

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source