variable / @typed/fx/RefTrie

longestPrefixOf

Get the longest prefix of a key that exists in the Trie.

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

Import

import { longestPrefixOf } from "@typed/fx/RefTrie";

Signatures

export declare const longestPrefixOf: {
    (key: string): <V, E, R>(ref: RefTrie<V, E, R>) => RefSubject.Computed<[
        string,
        V
    ] | undefined, E, R>;
    <V, E, R>(ref: RefTrie<V, E, R>, key: string): RefSubject.Computed<[
        string,
        V
    ] | undefined, E, R>;
};

Why

Models a longest-prefix lookup as Filtered state: an absent match fails an Effect read with NoSuchElementError, while later pushes can make a match available.

Ownership and lifetime

The longest prefix of 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