Skip to content

Dependents

Lszaboo edited this page Nov 9, 2025 · 3 revisions

Dependent class

As the wiki discussed in previous pages, Juliagebra relies on a Dependency graph to manage itself, so we have to have a class for the nodes, and they are called and implemented by the Dependent abstract class.

This class is designed as abstract, because by itself it can't function in the graph. It has some abstract methods which must be specialized by inheriting from this class. So if one would like to add their own nodes to the graph, they would have to inherit from Dependent and have to define it's abstract methods.

Structure

Let's take a look at how this class is defined:

mutable struct Dependent
    _graphID::Int                       
    _graphParents::Vector{DependentDNA}   
    _dependentChain::DependentChain
    _callback::Function
end

As we can see, every Dependent will be assigned to a graph via _graphID.

We also store who this node depends on in the Dependent graph (who has to be updated before updating this Node) in _graphParents.

The _callback function stores how the Dependent should react, when it is updated, evaluated in the Dependency graph.

DependentChain

The Dependent class also has a field with type DependentChain.

This object stores a reference to every other Dependent, Observed, Observers which have to be evaluated, updated, when an instance of this dependent is evaluated as a source node.

This object stores for efficient graph evaluation the Dependents and Observervers in a special way.

Nodes under Graph evaluation

evalGraph

When the evalGraph function is called on a Dependent, the system will think that that specific dependent was changed by the User, so it will start updating the nodes that are reachable from this Dependent (by the three invariant rules described in the Dependency graph page).

Let's take a look at this example:

DependencyGraph03

So calling evalGraph will produce the following callstack.

onGraphEval

The onGraphEval method is meant to represent how a Dependent should update itself if it's _graphParents change state.

This method must be defined in inherited classes.

afterGraphEval

The afterGraphEval method is meant to represent what a Dependent should do after it is updated in the graph.

By default for standard Dependents, this methos does nothing.

Dispatched eval helper functions

Wiki navigation sidebar

Legend:

  • ✅: Up-to-date
  • 🏗️: Needs some work
  • ❌: Unusable
  1. 🏗️ Home
  2. 🏗️ Developer Guide
    1. Composition Subclassing
    2. Core Graph
    3. 🏗️ Dependents
    4. 🏗️ Observer and Observed
    5. 🏗️ Plans
    6. 🏗️ Rendered Dependents
    7. Macro Constructors

Clone this wiki locally