Skip to main content

Dependency

The edge between two nodes in Octo's graph.

A dependency is directed, and carries two things: an optional parent/child relationship, and a set of behaviors. A behavior states an ordering rule - "when this field of from is added, the matching action on to must have run first" - and it is those rules that let Octo order a transaction correctly instead of guessing.

Models create dependencies through addChild() and addRelationship(); you rarely construct one.

@group

Functions/Dependency

@see

Definition of Dependencies.

Index

Constructors

constructor

  • Dependency(from: UnknownNode, to: UnknownNode): Dependency
  • Parameters

    • from: UnknownNode

      The node this dependency points from.

    • to: UnknownNode

      The node this dependency points to.

    Returns Dependency

Properties

readonlyfrom

from: UnknownNode

The node this dependency points from.

readonlyto

to: UnknownNode

The node this dependency points to.

Methods

addBehavior

  • To declare an ordering rule: when onAction happens to onField of from, then forAction on toField of to must have been applied first. Adding the same behavior twice is a no-op.


    Parameters

    Returns void

addChildRelationship

  • addChildRelationship(onField: string, toField: string): void
  • To mark to as the child of from.

    @throws

    DependencyError If this dependency already has a relationship.


    Parameters

    • onField: string
    • toField: string

    Returns void

addParentRelationship

  • addParentRelationship(onField: string, toField: string): void
  • To mark to as the parent of from.

    @throws

    DependencyError If this dependency already has a relationship.


    Parameters

    • onField: string
    • toField: string

    Returns void

getRelationship

  • The relationship between the two nodes, if one was declared.


    Returns { onField: string; toField: string; type: DependencyRelationship } | undefined

hasMatchingBehavior

  • hasMatchingBehavior(onField?: string, onAction?: DiffAction, toField?: string, forAction?: DiffAction): boolean
  • Whether any behavior matches every argument given. Arguments left out match anything.


    Parameters

    • optionalonField: string
    • optionalonAction: DiffAction
    • optionaltoField: string
    • optionalforAction: DiffAction

    Returns boolean

isChildRelationship

  • isChildRelationship(): boolean
  • Whether to is a child of from.


    Returns boolean

isEqual

  • Whether both dependencies connect the same two nodes, in the same direction.


    Parameters

    Returns boolean

isParentRelationship

  • isParentRelationship(): boolean
  • Whether to is a parent of from.


    Returns boolean

removeBehavior