UNPKG

@adaptabletools/adaptable

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

37 lines (36 loc) 1.74 kB
import { ApiBase } from '../Implementation/ApiBase'; export class TeamSharingInternalApi extends ApiBase { /** * Retrieves shared entry dependencies. */ getSharedEntryDependencies(sharedEntity) { const allEntities = this.getTeamSharingApi().getLoadedAdaptableSharedEntities(); return (sharedEntity?.EntityDependencyIds ?? []).map((id) => allEntities.find((entity) => entity.Uuid === id)); } waitForTeamSharingImportEnd() { // we have no deterministic means to ensure the teamsharing import is finished (because the import actions are opaque and may have side-effects) // therefore we will listen for state changes and // if the state was unchanged in the last `waitForStableState` ms, we assume/hope the import is finished const waitForStableState = 1000; const waitThreshold = 5000; return new Promise((resolve, reject) => { let pollTimer; // stop the poll after `waitThreshold` ms, if the state hasn't stabilised until now, it probably never will... let breakTimer = setTimeout(() => { unsubscribe?.(); clearTimeout(pollTimer); reject(false); }, waitThreshold); // poll state for changes: const unsubscribe = this.getEventApi().on('AdaptableStateChanged', () => { clearTimeout(pollTimer); pollTimer = setTimeout(() => { // state is stable, cleanup all subscriptions before returning unsubscribe(); clearTimeout(breakTimer); resolve(true); }, waitForStableState); }); }); } }