ResourceStore
A store holding all the resources to be rendered into a Scheduler.
This store only accepts a model class inheriting from ResourceModel.
A ResourceStore is usually connected to a project, which binds it to other related stores (EventStore, AssignmentStore and DependencyStore). The project also handles references (assignments, events) 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():
resourceStore.data = [{ id }, ...];
// references (assignments, events) not resolved yet
await resourceStore.project.commitAsync();
// now they are
Using loadDataAsync():
await resourceStore.loadDataAsync([{ id }, ...]);
// references (assignments, events) are resolved
Configs
80
Configs
80Common
Advanced
Chained store
Filtering
Other
Paging
Records
Remote
Tree
Properties
77
Properties
77Common
Class hierarchy
Records
Applies a new dataset to the ResourceStore. Use it to plug externally fetched data into the store.
NOTE: References (events, assignments) on the resources are determined async by a calculation engine. Thus they cannot be directly accessed after assigning the new dataset.
For example:
resourceStore.data = [{ id }];
// resourceStore.first.events is not yet available
To guarantee references are available, wait for calculations for finish:
resourceStore.data = [{ id }];
await resourceStore.project.commitAsync();
// resourceStore.first.events is available
Alternatively use loadDataAsync() instead:
await resourceStore.loadDataAsync([{ id }]);
// resourceStore.first.events is available
Advanced
CRUD
Filtering
Misc
Models & Stores
Other
Remote
Functions
104
Functions
104CRUD
Add resources to the store.
NOTE: References (events, assignments) on the resources are determined async by a calculation engine. Thus they cannot be directly accessed after using this function.
For example:
const [resource] = resourceStore.add({ id });
// resource.events is not yet available
To guarantee references are set up, wait for calculations for finish:
const [resource] = resourceStore.add({ id });
await resourceStore.project.commitAsync();
// resource.events is available (assuming EventStore is loaded and so on)
Alternatively use addAsync() instead:
const [resource] = await resourceStore.addAsync({ id });
// resource.events is available (assuming EventStore is loaded and so on)
| Parameter | Type | Description |
|---|---|---|
records | ResourceModel | ResourceModel[] | ResourceModelConfig | ResourceModelConfig[] | Array of records/data or a single record/data to add to store |
silent | Boolean | Specify |
Added records
Add resources to the store and triggers calculations directly after. Await this function to have up to date references on the added resources.
const [resource] = await resourceStore.addAsync({ id });
// resource.events is available (assuming EventStore is loaded and so on)
| Parameter | Type | Description |
|---|---|---|
records | ResourceModel | ResourceModel[] | ResourceModelConfig | ResourceModelConfig[] | Array of records/data or a single record/data to add to store |
silent | Boolean | Specify |
Added records
Applies a new dataset to the ResourceStore and triggers calculations directly after. Use it to plug externally fetched data into the store.
await resourceStore.loadDataAsync([{ id }]);
// resourceStore.first.events is available
| Parameter | Type | Description |
|---|---|---|
data | ResourceModelConfig[] | Array of ResourceModel data objects |
Other
Returns all resources that have no events assigned during the specified time range.
| Parameter | Type | Description |
|---|---|---|
startDate | Date | Time range start date |
endDate | Date | Time range end date |
Resources without events