ReactiveDag.Graph (reactive_dag v0.17.0-rc.2)

Copy Markdown View Source

Pure DAG construction: a list of ReactiveDag.Cell → a ReactiveDag.Plan.

No live data — only the plan (cells, parent edges, depths). Validates that every referenced input exists and the graph is acyclic (raises ArgumentError on a dangling input or cycle; a host's DSL transformer should catch these at compile time, but the runtime builder re-checks so a hand-built plan can't wedge the drain).

Summary

Functions

The parents whose keys should be dirtied when child changed, applying the host's key_rule module (a ReactiveDag.KeyRule impl). The rule sees the parent, the specific child input, and the changed keys, and returns :all (whole-cell recompute, the "*" wildcard) or {:keys, mapped}.

Functions

build(cells)

@spec build([ReactiveDag.Cell.t()]) :: ReactiveDag.Plan.t()

dirty_parents(plan, child_id, keys, key_rule \\ ReactiveDag.KeyRule, priors \\ %{})

@spec dirty_parents(
  ReactiveDag.Plan.t(),
  ReactiveDag.Cell.id(),
  [String.t()],
  module(),
  map()
) :: [
  {ReactiveDag.Cell.id(), [String.t()]}
]

The parents whose keys should be dirtied when child changed, applying the host's key_rule module (a ReactiveDag.KeyRule impl). The rule sees the parent, the specific child input, and the changed keys, and returns :all (whole-cell recompute, the "*" wildcard) or {:keys, mapped}.

Returns [{parent_id, [key]}]. key_rule defaults to identity mapping.

priors maps a changed key to the child row AS IT WAS when marked dirty (see ReactiveDag.Frontier). A rule that implements rule/4 receives it and can derive a claim from a row that no longer exists; one implementing only rule/3 is called exactly as before, so a host's own KeyRule keeps working untouched.