variable / @typed/fx/RefArray

modifyAt

Modify the value at a particular index of a RefArray.

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

Import

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

Signatures

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

Why

Keeps modify at atomic with respect to competing RefSubject writes instead of splitting the read and replacement into separate effects.

Ownership and lifetime

Running modify at performs one serialized array transition and resolves with its committed value. It acquires no resource; failures and services remain those of the source ref.

Other public imports

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

Source