The Node class is the base class for all atoms, molecules, and organisms.

It is used to create a tree of the following form:

DesignSystem -> Atoms     -> <SomeAtom>     -> <Properties of SomeAtom>
-> Molecules -> <SomeMolecule> -> <Properties of SomeMolecule>
-> Organisms -> <SomeOrganism> -> <Properties of SomeOrganism>
-> Layers -> <SomeLayer>
-> Code -> <SomeCodeGenerator>

It is also used to form a dependency graph between nodes of the tree.

Each node may depend on other nodes and inversely may be depended on by other nodes. A node is considered "initialized" only when all children are initialized. A Prop (a leaf node) is considered "initialized" if it is either not a required property or it is required but has a value. A node is considered "enabled" only when all dependency nodes are "initialized". Listeners are notified when it transitions the enabled status of a node changes.

Hierarchy (view full)

Implements

Properties

key: string

The unique key for the node. It is unique from all other nodes in the ThemeBuilder

name: string

The name of the node, which is unique relative to it's siblings

Methods

  • Add a dependency to another node in the tree

    Parameters

    Returns void

  • Get the design system

    Returns IDesignSystem

  • Return the keys of all properties which are required and not initialized.

    Returns string[]

    Returns the keys of all properties which are required and not initialized.

  • Determine if this node is enabled. A node is enabled if all other nodes on which this node depends have been initialized.

    Returns boolean

    True if enabled, or false otherwise.

  • Determine if this node is initialized.

    If this node is a property, it is initialized if it is not required to have a value, or if it is required and has either a default or non-default value.

    Returns boolean

    True if initialized, or false otherwise.

  • Set a listener on this node

    Parameters

    • name: string

      The name of the listener.

    • callback: EventCallback

      The callback to call when an event occurs.

    • OptionaleventTypes: EventType[]

      The types of events to wait for. If none are specified, listen for all events.

    Returns ListenerSubscription

    The ListenerSubscription which should be canceled to stop listening.

  • Store persistently the state of the design system.

    Returns Promise<void>