# Collection.register

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

## Signatures

```ts
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](https://tylors.github.io/typed/reference/symbols/QHR5cGVkL3VpL0NvbGxlY3Rpb24jbWFrZVN0YXRl/). Inside the linked Effect
program invoke `yield* register(collection, { id: "save", value: "save" })`, then read the
collection to observe the inserted item.
