new EntityCollection(owneropt)
An observable collection of
Entity
instances where each entity has a unique id.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
owner |
DataSource | CompositeEntityCollection |
<optional> |
The data source (or composite entity collection) which created this collection. |
- Source:
Members
(readonly) collectionChanged :Event
Gets the event that is fired when entities are added or removed from the collection.
The generated event is a
EntityCollection.collectionChangedEventCallback
.
Type:
- Source:
(readonly) id :String
Gets a globally unique identifier for this collection.
Type:
- String
- Source:
(readonly) owner :DataSource|CompositeEntityCollection
Gets the owner of this entity collection, ie. the data source or composite entity collection which created it.
Type:
- Source:
show :Boolean
Gets whether or not this entity collection should be
displayed. When true, each entity is only displayed if
its own show property is also true.
Type:
- Boolean
- Source:
(readonly) values :Array.<Entity>
Gets the array of Entity instances in the collection.
This array should not be modified directly.
Type:
- Array.<Entity>
- Source:
Methods
(static) collectionChangedEventCallback(collection, added, removed, changed)
The signature of the event generated by
EntityCollection#collectionChanged
.
Parameters:
Name | Type | Description |
---|---|---|
collection |
EntityCollection | The collection that triggered the event. |
added |
Array.<Entity> | The array of Entity instances that have been added to the collection. |
removed |
Array.<Entity> | The array of Entity instances that have been removed from the collection. |
changed |
Array.<Entity> | The array of Entity instances that have been modified. |
- Source:
add(entity) → {Entity}
Add an entity to the collection.
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | The entity to be added. |
- Source:
Throws:
-
An entity with
already exists in this collection. - Type
- DeveloperError
Returns:
The entity that was added.
- Type
- Entity
computeAvailability() → {TimeInterval}
Computes the maximum availability of the entities in the collection.
If the collection contains a mix of infinitely available data and non-infinite data,
it will return the interval pertaining to the non-infinite data only. If all
data is infinite, an infinite interval will be returned.
- Source:
Returns:
The availability of entities in the collection.
- Type
- TimeInterval
contains(entity) → {Boolean}
Returns true if the provided entity is in this collection, false otherwise.
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | The entity. |
- Source:
Returns:
true if the provided entity is in this collection, false otherwise.
- Type
- Boolean
getById(id) → {Entity}
Gets an entity with the specified id.
Parameters:
Name | Type | Description |
---|---|---|
id |
Object | The id of the entity to retrieve. |
- Source:
Returns:
The entity with the provided id or undefined if the id did not exist in the collection.
- Type
- Entity
getOrCreateEntity(id) → {Entity}
Gets an entity with the specified id or creates it and adds it to the collection if it does not exist.
Parameters:
Name | Type | Description |
---|---|---|
id |
Object | The id of the entity to retrieve or create. |
- Source:
Returns:
The new or existing object.
- Type
- Entity
remove(entity) → {Boolean}
Removes an entity from the collection.
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | The entity to be removed. |
- Source:
Returns:
true if the item was removed, false if it did not exist in the collection.
- Type
- Boolean
removeAll()
Removes all Entities from the collection.
- Source:
removeById(id) → {Boolean}
Removes an entity with the provided id from the collection.
Parameters:
Name | Type | Description |
---|---|---|
id |
Object | The id of the entity to remove. |
- Source:
Returns:
true if the item was removed, false if no item with the provided id existed in the collection.
- Type
- Boolean
resumeEvents()
Resumes raising
EntityCollection#collectionChanged
events immediately
when an item is added or removed. Any modifications made while while events were suspended
will be triggered as a single event when this function is called.
This function is reference counted and can safely be called multiple times as long as there
are corresponding calls to EntityCollection#resumeEvents
.
- Source:
Throws:
-
resumeEvents can not be called before suspendEvents.
- Type
- DeveloperError
suspendEvents()
Prevents
EntityCollection#collectionChanged
events from being raised
until a corresponding call is made to EntityCollection#resumeEvents
, at which
point a single event will be raised that covers all suspended operations.
This allows for many items to be added and removed efficiently.
This function can be safely called multiple times as long as there
are corresponding calls to EntityCollection#resumeEvents
.
- Source: