* 批量初始化查询结果 * * @param entities 初始实体列表
(entities: readonly Entity[])
| 341 | * @param entities 初始实体列表 |
| 342 | */ |
| 343 | public initializeWith(entities: readonly Entity[]): void { |
| 344 | // 清空现有结果 |
| 345 | this._entities.length = 0; |
| 346 | this._entityIdSet.clear(); |
| 347 | this._snapshot = null; // 使快照失效 | Invalidate snapshot |
| 348 | |
| 349 | // 筛选匹配的实体 |
| 350 | for (const entity of entities) { |
| 351 | if (this.matches(entity)) { |
| 352 | this._entities.push(entity); |
| 353 | this._entityIdSet.add(entity.id); |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | if (this._config.debug) { |
| 358 | logger.debug(`ReactiveQuery ${this._id}: 初始化 ${this._entities.length} 个实体`); |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | /** |
| 363 | * 添加到批量变化缓存 |
no test coverage detected