• Register a derived node whose compute can be hot-swapped.

    The returned LiveDerivedHandle exposes a replace(next) method that updates the closure and bumps a hidden version Input in a single commit, producing exactly one downstream notification.

    Type Parameters

    • T

      The derived value type.

    Parameters

    • graph: Graph

      The graph to register the derivation against.

    • id: string

      Stable id for the derivation; must be unique within graph.

    • initial: Compute<T>

      The initial compute closure.

    Returns LiveDerivedHandle<T>

    A handle whose replace swaps the compute in-place.

    const total = liveDerived(graph, 'total', (get) => get(a) + get(b))
    total.replace((get) => get(a) * get(b)) // one commit, one notify