可观察的集合 An observable collection of
Entity 每个实体都有唯一 ID 的实例。 instances where each entity has a unique id.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
owner |
DataSource | CompositeEntityCollection | 可选 optional 创建此集合的数据源(或复合实体集合)。 The data source (or composite entity collection) which created this collection. |
成员 Members
readonly collectionChanged : Event.<EntityCollection.CollectionChangedEventCallback>
获取在集合中添加或删除实体时触发的事件。生成的事件是 Gets the event that is fired when entities are added or removed from the collection. The generated event is a
EntityCollection.CollectionChangedEventCallback.
获取此集合的全局唯一标识符。 Gets a globally unique identifier for this collection.
readonly owner : DataSource|CompositeEntityCollection
获取此实体集合的所有者,即。创建它的数据源或复合实体集合。 Gets the owner of this entity collection, ie. the data source or composite entity collection which created it.
获取是否应显示此实体集合。当为 true 时,每个实体仅在其自己的 show 属性也为 true 时才显示。 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.
readonly values : Array.<Entity>
获取集合中Entity实例的数组。不应直接修改该数组。 Gets the array of Entity instances in the collection. This array should not be modified directly.
方法 Methods
add(entity) → Entity
将实体添加到集合中。 Add an entity to the collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
entity |
Entity | Entity.ConstructorOptions | 要添加的实体。 The entity to be added. |
返回: Returns:
添加的实体。 The entity that was added.
抛出: Throws:
-
DeveloperError : An entity with
该集合中已存在。 already exists in this collection.
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.
返回: Returns:
集合中实体的可用性。 The availability of entities in the collection.
如果提供的实体在此集合中,则返回 true,否则返回 false。 Returns true if the provided entity is in this collection, false otherwise.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
entity |
Entity | 实体。 The entity. |
返回: Returns:
如果提供的实体在此集合中,则为 true,否则为 false。 true if the provided entity is in this collection, false otherwise.
getById(id) → Entity|undefined
获取具有指定 id 的实体。 Gets an entity with the specified id.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
id |
string | 要检索的实体的 ID。 The id of the entity to retrieve. |
返回: Returns:
具有提供的 id 的实体,如果集合中不存在该 id,则实体未定义。 The entity with the provided id or undefined if the id did not exist in the collection.
getOrCreateEntity(id) → Entity
获取具有指定 id 的实体,或者创建它并将其添加到集合(如果不存在)。 Gets an entity with the specified id or creates it and adds it to the collection if it does not exist.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
id |
string | 要检索或创建的实体的 ID。 The id of the entity to retrieve or create. |
返回: Returns:
新的或现有的对象。 The new or existing object.
从集合中删除一个实体。 Removes an entity from the collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
entity |
Entity | 要删除的实体。 The entity to be removed. |
返回: Returns:
如果该项目已被删除,则为 true;如果集合中不存在该项目,则为 false。 true if the item was removed, false if it did not exist in the collection.
从集合中删除所有实体。 Removes all Entities from the collection.
从集合中删除具有提供的 id 的实体。 Removes an entity with the provided id from the collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
id |
string | 要删除的实体的 ID。 The id of the entity to remove. |
返回: Returns:
如果该项目已被删除,则为 true;如果集合中不存在具有所提供 id 的项目,则为 false。 true if the item was removed, false if no item with the provided id existed in the collection.
恢复筹集资金 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.
抛出: Throws:
-
DeveloperError :resumeEvents不能在suspendEvents之前调用。 : resumeEvents can not be called before 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.
类型定义 Type Definitions
生成的事件的签名 The signature of the event generated by
EntityCollection#collectionChanged.
| 名称 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. |
