Class DependencyEngine<CalculationData>

Type Parameters

  • CalculationData = any

Hierarchy (view full)

Constructors

Properties

editor: Editor
events: {
    afterNodeCalculation: BaklavaEvent<AfterNodeCalculationEventData, BaseEngine<CalculationData, []>>;
    afterRun: BaklavaEvent<CalculationResult, BaseEngine<CalculationData, []>>;
    beforeNodeCalculation: BaklavaEvent<BeforeNodeCalculationEventData, BaseEngine<CalculationData, []>>;
    beforeRun: PreventableBaklavaEvent<CalculationData, BaseEngine<CalculationData, []>>;
    statusChange: BaklavaEvent<EngineStatus, BaseEngine<CalculationData, []>>;
} = ...

Type declaration

hooks: {
    gatherCalculationData: SequentialHook<undefined | CalculationData, BaseEngine<CalculationData, []>, CalculationData>;
    transferData: DynamicSequentialHook<any, IConnection, any>;
} = ...
recalculateOrder: boolean = true

Accessors

Methods

  • Force the engine to recalculate the node execution order before the next run. This is normally done automatically. Use this method if the default change detection does not work in your scenario.

    Returns void

  • Use the gatherCalculationData hook to get the calculation data

    Parameters

    • Rest...args: []

      The calculation arguments with which the engine's calculate method will be called (in addition to the calculationData)

    Returns Promise<null | CalculationResult>

    The calculation result

  • Check whether a connection can be created. A connection can not be created when it would result in a cyclic graph.

    Parameters

    • from: NodeInterface<any>

      The interface from which the connection would start

    • to: NodeInterface<any>

      The interface where the connection would end

    Returns CheckConnectionHookResult

    Whether the connection can be created

  • Overwrite this method to perform the calculation

    Parameters

    • calculationData: CalculationData

      The data which is provided to each node's calculate method

    Returns Promise<CalculationResult>

    The calculation result

  • This method is called whenever the graph or values of node interfaces have been changed. You can overwrite this method to automatically trigger a calculation on change. Note: This method is only called when the engine is either idle or running.

    Parameters

    • recalculateOrder: boolean

      Whether the change modified the graph itself, e. g. a connection or a node was added/removed

    Returns void

  • Run a non-root graph. This method can be used by nodes to calculate internal graphs (e. g. GraphNode). DO NOT use this method for calculation of the root graph! It won't emit any events.

    Parameters

    • graph: Graph

      The graph to execute

    • inputs: Map<string, any>

      Map<NodeInterfaceId, value>

    • calculationData: CalculationData

      The data which is provided to each node's calculate method

    Returns Promise<CalculationResult>

    A promise that resolves to a map that maps rootNodes to their calculated value (what the calculation function of the node returned)

  • Calculate all nodes once. This will automatically calculate the node calculation order if necessary and transfer values between connected node interfaces.

    Parameters

    • calculationData: CalculationData

      The data which is provided to each node's calculate method

    • Rest...args: []

    Returns Promise<null | CalculationResult>

    A promise that resolves to either

    • a map from each node's id to its calculated value (what the calculation function of the node returned)
    • null if the calculation was prevented from the beforeRun event
  • Validate the result of a node's calculate method. A result is valid if:

    • is has the correct format (it must be an object, where the key is the interface key and the value is the output value for that interface)
    • every output interface has a value assigned to it (null and undefined are also valid, but the key must exist in the object)

    Parameters

    • node: AbstractNode

      The node which produced the output data

    • output: any

      The result of the node's calculate method

    Returns void