一个可观察的
Entity 实例集合,其中每个实体都有唯一的 id。
| Name | Type | Description |
|---|---|---|
owner |
DataSource | CompositeEntityCollection | optional 创建此集合的数据源(或组合实体集合)。 |
Members
readonly collectionChanged : Event.<EntityCollection.CollectionChangedEventCallback>
获取当实体被添加或移除出集合时触发的事件。
生成的事件是一个
EntityCollection.CollectionChangedEventCallback。
获取此集合的全局唯一标识符。
readonly owner : DataSource|CompositeEntityCollection
获取此实体集合的所有者,即创建它的数据源或组合实体集合。
获取此实体集合是否应被显示。当为 true 时,每个实体仅在其自身的 show 属性也为 true 时才会显示。
readonly values : Array.<Entity>
获取集合中的 Entity 实例数组。
不应直接修改此数组。
Methods
add(entity) → Entity
向集合中添加实体。
| Name | Type | Description |
|---|---|---|
entity |
Entity | Entity.ConstructorOptions | 要添加的实体。 |
Returns:
被添加的实体。
Throws:
-
DeveloperError : 此集合中已存在 id 为
的实体。
computeAvailability() → TimeInterval
计算集合中实体的最大可用时间范围。
如果集合同时包含无限可用数据和有限可用数据,
则仅返回与有限数据相关的区间。如果所有数据都是无限的,则返回无限区间。
Returns:
集合中实体的可用时间范围。
如果所提供的实体在此集合中则返回 true,否则返回 false。
| Name | Type | Description |
|---|---|---|
entity |
Entity | 实体。 |
Returns:
如果所提供的实体在此集合中则为 true,否则为 false。
getById(id) → Entity|undefined
获取具有指定 id 的实体。
| Name | Type | Description |
|---|---|---|
id |
string | 要获取的实体的 id。 |
Returns:
具有所提供 id 的实体;如果该 id 在集合中不存在则为 undefined。
getOrCreateEntity(id) → Entity
获取具有指定 id 的实体;如果该 id 不存在,则创建实体并将其添加到集合中。
| Name | Type | Description |
|---|---|---|
id |
string | 要获取或创建的实体的 id。 |
Returns:
新的或已有的对象。
从集合中移除一个实体。
| Name | Type | Description |
|---|---|---|
entity |
Entity | 要移除的实体。 |
Returns:
如果项目被移除则为 true,如果它不存在于集合中则为 false。
从集合中移除所有实体。
从集合中移除具有所提供 id 的实体。
| Name | Type | Description |
|---|---|---|
id |
string | 要移除的实体的 id。 |
Returns:
如果项目被移除则为 true,如果集合中不存在具有所提供 id 的项目则为 false。
当项目被添加或移除时,立即恢复触发
EntityCollection#collectionChanged 事件。
在事件被挂起期间所做的任何修改,将在调用此函数时作为单个事件被触发。
此函数使用引用计数,只要有相应的对 EntityCollection#resumeEvents 的调用,就可以安全地多次调用。
Throws:
-
DeveloperError : resumeEvents 不能在 suspendEvents 之前调用。
阻止触发
EntityCollection#collectionChanged 事件,直到对 EntityCollection#resumeEvents 进行相应调用为止,届时将触发一个涵盖所有被挂起操作的单一事件。
这使得可以高效地添加和移除许多项目。
此函数可以安全地多次调用,只要有相应的对 EntityCollection#resumeEvents 的调用。
Type Definitions
由
EntityCollection#collectionChanged 生成的事件的签名。
| Name | Type | Description |
|---|---|---|
collection |
EntityCollection | 触发该事件的集合。 |
added |
Array.<Entity> |
已被添加到集合中的 Entity 实例数组。 |
removed |
Array.<Entity> |
已从集合中移除的 Entity 实例数组。 |
changed |
Array.<Entity> |
已被修改的 Entity 实例数组。 |
