new DynamicObjectCollection
An observable collection of DynamicObject instances where each object has a unique id.
Members
-
collectionChanged :Event
-
Gets the event that is fired when objects are added or removed from the collection. The generated event is a DynamicObjectCollection.collectionChangedEventCallback.
-
id :String
-
Gets a globally unique identifier for this collection.
Methods
-
add
-
Add an object to the collection.
Parameters:
Name Type Description dynamicObject
DynamicObject The object to be added. Throws:
DeveloperError : An object withalready exists in this collection. -
computeAvailability
-
Computes the maximum availability of the DynamicObjects 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.
Returns:
TimeInterval The availability of DynamicObjects in the collection. -
getById
-
Gets an object with the specified id.
Parameters:
Name Type Description id
Object The id of the object to retrieve. Returns:
DynamicObject The object with the provided id or undefined if the id did not exist in the collection. -
getObjects
-
Gets the array of DynamicObject instances in the collection. The array should not be modified directly.
Returns:
Array the array of DynamicObject instances in the collection. -
getOrCreateObject
-
Gets an object 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 object to retrieve or create. Returns:
DynamicObject The new or existing object. -
remove
-
Removes an object from the collection.
Parameters:
Name Type Description dynamicObject
DynamicObject The object to be added. Returns:
Boolean true if the item was removed, false if it did not exist in the collection. -
removeAll
-
Removes all objects from the collection.
-
removeById
-
Removes an object with the provided id from the collection.
Parameters:
Name Type Description id
Object The id of the object to remove. Returns:
Boolean true if the item was removed, false if no item with the provided id existed in the collection. -
resumeEvents
-
Resumes raising DynamicObjectCollection#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 DynamicObjectCollection#resumeEvents.
Throws:
DeveloperError : resumeEvents can not be called before suspendEvents. -
suspendEvents
-
Prevents DynamicObjectCollection#collectionChanged events from being raised until a corresponding call is made to DynamicObjectCollection#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 DynamicObjectCollection#resumeEvents.
-
<static> collectionChangedEventCallback
-
The signature of the event generated by DynamicObjectCollection#collectionChanged.
Parameters:
Name Type Description collection
DynamicObjectCollection The collection that triggered the event. added
Array The array of DynamicObject instances that have been added to the collection. removed
Array The array of DynamicObject instances that have been removed from the collection.