variable / @typed/fx/RefArray

map

Map (Endomorphic) the values of a RefArray.

Package version
2.0.0-beta.13
Category
State updates
Since
1.18.0

Import

import { map } from "@typed/fx/RefArray";

Signatures

export declare const map: {
    <A>(f: (a: A, index: number) => A): <E, R>(ref: RefArray<A, E, R>) => RefSubject.Computed<ReadonlyArray<A>, E, R>;
    <A, E, R>(ref: RefArray<A, E, R>, f: (a: A, index: number) => A): RefSubject.Computed<ReadonlyArray<A>, E, R>;
};

Why

The implementation applies the endomorphic map through RefSubject.update, replacing the writable RefArray in one serialized transition. The published Computed return type does not describe that runtime behavior.

Ownership and lifetime

The Effect starts when run, participates in the source ref’s serialized update boundary, and acquires no resource. It returns the committed array and retains the ref’s E and R channels.

Known API defect

The public overloads currently declare Computed<ReadonlyArray<A>, E, R>, but the implementation returns the update Effect from RefSubject.update. This documentation reports the shipped mismatch; changing that signature or runtime behavior requires a separate compatibility decision.

Other public imports

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

Source