variable / @typed/fx/RefIterable

countBy

Count elements satisfying a predicate.

Package version
2.0.0-beta.13
Category
Derived queries
Since
1.18.0

Import

import { countBy } from "@typed/fx/RefIterable";

Signatures

export declare const countBy: {
    <A>(predicate: (a: A) => boolean): <E, R>(ref: RefIterable<A, E, R>) => RefSubject.Computed<number, E, R>;
    <A, E, R>(ref: RefIterable<A, E, R>, predicate: (a: A) => boolean): RefSubject.Computed<number, E, R>;
};

Why

Makes count by a live projection of the iterable; consumers can sample it now or observe it without copying the source state.

Ownership and lifetime

The count by view retains no independent state. An Effect read samples the source once; Fx observation follows later pushes and its observing Scope owns subscription cleanup.

Other public imports

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

Source