Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private pushNext(categoryIds: Id64Arg, func: QueueFunc): void {
assert(undefined !== this._current);
assert(undefined !== this._request);
if (undefined === this._next) {
// We have a request currently in process and none pending.
// We could potentially determine that this request doesn't require any categories that are not already loaded or being loaded by the current request.
// But we will find that out (synchronously) when current request completes, unless more requests come in. Probably not worth it.
this._next = new QueueEntry(Id64.toIdSet(categoryIds, true), func);
} else {
// We have a request currently in process, and one or more pending. Append this one to the pending.
this._next.funcs.push(func);
Id64.forEach(categoryIds, (categoryId) => {
this._next!.categoryIds.add(categoryId);
});
}
}
}
public load(categoryIds: Id64Arg): SubCategoriesRequest | undefined {
let missing: Id64Set | undefined;
Id64.forEach(categoryIds, (catId) => {
if (undefined === this._byCategoryId.get(catId)) {
if (undefined === missing)
missing = new Set();
missing.add(catId);
}
});
if (undefined === missing)
return undefined;
const request = new SubCategoriesCache.Request(missing, this._imodel);
const promise = request.dispatch().then((result?: SubCategoriesCache.Result) => {
if (undefined !== result)
this.processResults(result, missing!);
public addCategories(arg: Id64Arg): void {
Id64.forEach(arg, (id) => this.categories.add(id));
}
public addModels(arg: Id64Arg): void {
Id64.forEach(arg, (id) => this.models.add(id));
}
public async remove(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise {
const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);
Id64.forEach(transientIds, (id) => keys.add({ className: TRANSIENT_ELEMENT_CLASSNAME, id }));
this.manager.removeFromSelection(this.name, this.imodel, keys, level);
}
public async replace(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise {
private _add(elem: Id64Arg, sendEvent = true): boolean {
const oldSize = this.elements.size;
Id64.forEach(elem, (id) => this.elements.add(id));
const changed = oldSize !== this.elements.size;
if (sendEvent && changed)
this.sendChangedEvent({ type: SelectionSetEventType.Add, set: this, added: elem });
return changed;
}
private _remove(elem: Id64Arg, sendEvent = true): boolean {
const oldSize = this.elements.size;
Id64.forEach(elem, (id) => this.elements.delete(id));
const changed = oldSize !== this.elements.size;
if (sendEvent && changed)
this.sendChangedEvent({ type: SelectionSetEventType.Remove, set: this, removed: elem });
return changed;
}
public filterLoaded(modelIds: Id64Arg): Id64Set | undefined {
let unloaded: Set | undefined;
Id64.forEach(modelIds, (id) => {
if (undefined === this.getLoaded(id)) {
if (undefined === unloaded)
unloaded = new Set();
unloaded.add(id);
}
});
return unloaded;
}