DependencyStore
A store representing a collection of dependencies between events in the EventStore.
This store only accepts a model class inheriting from DependencyModel.
A DependencyStore is usually connected to a project, which binds it to other related stores (EventStore, AssignmentStore and ResourceStore). The project also handles references (fromEvent, toEvent) to related records for the records in the store.
Resolving the references happens async, records are not guaranteed to have up to date references until calculations
are finished. To be certain that references are resolved, call await project.commitAsync() after store actions. Or
use one of the xxAsync functions, such as loadDataAsync().
Using commitAsync():
dependencyStore.data = [{ from, to }, ...];
// references (fromEvent, toEvent) not resolved yet
await dependencyStore.project.commitAsync();
// now they are
Using loadDataAsync():
await dependencyStore.loadDataAsync([{ from, to }, ...]);
// references (fromEvent, toEvent) are resolved
Configs
82
Configs
82Common
Other
An array of allowed dependency types. When set, only the specified dependency types can be created. Use values from DependencyModel.Type:
0- StartToStart (SS)1- StartToEnd (SF)2- EndToStart (FS)3- EndToEnd (FF)
const scheduler = new Scheduler({
project : {
dependencyStore : {
// Only allow Finish-to-Start and Start-to-Start dependencies
allowedDependencyTypes : [DependencyModel.Type.EndToStart, DependencyModel.Type.EndToEnd]
}
}
});
When null (default), all dependency types are allowed.
This config affects:
- Drag-creating dependencies (invalid types will be rejected)
- The dependency editor type combo (only allowed types are shown)
- The Predecessors and Successors tabs in the Task Editor
Advanced
Chained store
Filtering
Models & Stores
Paging
Records
Remote
Tree
Properties
79
Properties
79Common
Class hierarchy
Records
Applies a new dataset to the DependencyStore. Use it to plug externally fetched data into the store.
NOTE: References (fromEvent, toEvent) on the dependencies are determined async by a calculation engine. Thus they cannot be directly accessed after assigning the new dataset.
For example:
dependencyStore.data = [{ from, to }];
// dependencyStore.first.fromEvent is not yet available
To guarantee references are available, wait for calculations for finish:
dependencyStore.data = [{ from, to }];
await dependencyStore.project.commitAsync();
// dependencyStore.first.fromEvent is available
Alternatively use loadDataAsync() instead:
await dependencyStore.loadDataAsync([{ from, to }]);
// dependencyStore.first.fromEvent is available
Advanced
CRUD
Filtering
Misc
Models & Stores
Other
Remote
Functions
110
Functions
110CRUD
Add dependencies to the store.
NOTE: References (fromEvent, toEvent) on the dependencies are determined async by a calculation engine. Thus they cannot be directly accessed after using this function.
For example:
const [dependency] = dependencyStore.add({ from, to });
// dependency.fromEvent is not yet available
To guarantee references are set up, wait for calculations for finish:
const [dependency] = dependencyStore.add({ from, to });
await dependencyStore.project.commitAsync();
// dependency.fromEvent is available (assuming EventStore is loaded and so on)
Alternatively use addAsync() instead:
const [dependency] = await dependencyStore.addAsync({ from, to });
// dependency.fromEvent is available (assuming EventStore is loaded and so on)
| Parameter | Type | Description |
|---|---|---|
records | DependencyModel | DependencyModel[] | DependencyModelConfig | DependencyModelConfig[] | Array of records/data or a single record/data to add to store |
silent | Boolean | Specify |
Added records
Add dependencies to the store and triggers calculations directly after. Await this function to have up to date references on the added dependencies.
const [dependency] = await dependencyStore.addAsync({ from, to });
// dependency.fromEvent is available (assuming EventStore is loaded and so on)
| Parameter | Type | Description |
|---|---|---|
records | DependencyModel | DependencyModel[] | DependencyModelConfig | DependencyModelConfig[] | Array of records/data or a single record/data to add to store |
silent | Boolean | Specify |
Added records
Applies a new dataset to the DependencyStore and triggers calculations directly after. Use it to plug externally fetched data into the store.
await dependencyStore.loadDataAsync([{ from, to }]);
// dependencyStore.first.fromEvent is available
| Parameter | Type | Description |
|---|---|---|
data | DependencyModelConfig[] | Array of DependencyModel data objects |
Other
Returns dependency model instance linking tasks with given ids. The dependency can be forward (from 1st task to 2nd) or backward (from 2nd to 1st).
| Parameter | Type | Description |
|---|---|---|
sourceEvent | EventModel | String | 1st event |
targetEvent | EventModel | String | 2nd event |
Returns all dependencies for a certain event (both incoming and outgoing)
| Parameter | Type | Description |
|---|---|---|
event | EventModel |
Returns a dependency model instance linking given events if such dependency exists in the store. The dependency can be forward (from 1st event to 2nd) or backward (from 2nd to 1st).
| Parameter | Type | Description |
|---|---|---|
sourceEvent | EventModel | String | |
targetEvent | EventModel | String |
Returns all dependencies highlighted with the given CSS class
| Parameter | Type | Description |
|---|---|---|
cls | String |
Returns true if the specified dependency type is allowed according to the
allowedDependencyTypes configuration.
| Parameter | Type | Description |
|---|---|---|
type | Number | Dependency Type |
Validation method used to validate a dependency. Override and return true to indicate that an
existing dependency between two tasks is valid. For a new dependency being created please see
isValidDependencyToCreate.
| Parameter | Type | Description |
|---|---|---|
dependencyOrFromId | DependencyModel | TimeSpan | Number | String | The dependency model, the from task/event or the id of the from task/event |
toId | TimeSpan | Number | String | To task/event or id thereof if the first parameter is not a dependency record |
type | Number | Dependency Type if the first parameter is not a dependency model instance. |
Validation method used to validate a dependency while creating. Override and return true to indicate that
a new dependency is valid to be created.
| Parameter | Type | Description |
|---|---|---|
fromId | TimeSpan | Number | String | From event/task or id |
toId | TimeSpan | Number | String | To event/task or id |
type | Number | Dependency Type |