v7.3.0

DependencyModel

This model represents a dependency between two events, usually added to a DependencyStore.

It is a subclass of the DependencyBaseModel class, which in its turn subclasses Model. Please refer to documentation of those classes to become familiar with the base interface of this class.

Fields and references

A Dependency has a few predefined fields, see Fields below. The name of any fields data source can be customized in the subclass, see the example below. Please also refer to Model for details.

class MyDependency extends DependencyModel {
  static get fields() {
    return [
      { name: 'to', dataSource: 'targetId' },
      { name: 'from', dataSource: 'sourceId' }
    ]);
  }
}

After load and project normalization, these references are accessible (assuming their respective stores are loaded):

  • fromEvent - The event on the start side of the dependency
  • toEvent - The event on the end side of the dependency

Async resolving of references

As described above, a dependency has links to events. These references are populated async, using the calculation engine of the project that the resource via its store is a part of. Because of this asyncness, references cannot be used immediately after modifications:

dependency.from = 2;
// dependency.fromEvent is not yet up to date

To make sure references are updated, wait for calculations to finish:

dependency.from = 2;
await dependency.project.commitAsync();
// dependency.fromEvent is up to date

As an alternative, you can also use setAsync() to trigger calculations directly after the change:

await dependency.setAsync({ from : 2});
// dependency.fromEvent is up to date

See also

No results

Properties

Properties are getters/setters or publicly accessible variables on this class

Source path

Scheduler/model/DependencyModel.js

Contents