/** @module @airtable/blocks/models: Abstract models */ /** */ import Sdk from '../sdk'; import { FlowAnyFunction, FlowAnyObject, TimeoutId } from '../private_utils'; import AbstractModel from './abstract_model'; /** * Abstract superclass for all Blocks SDK models that need to fetch async data. * * @docsPath models/advanced/AbstractModelWithAsyncData */ declare abstract class AbstractModelWithAsyncData extends AbstractModel { /** @internal */ static __DATA_UNLOAD_DELAY_MS: number; /** @internal */ static _shouldLoadDataForKey(key: string): boolean; /** @internal */ _isDataLoaded: boolean; /** @internal */ _pendingDataLoadPromise: Promise> | null; /** @internal */ _dataRetainCount: number; /** @internal */ _unloadDataTimeoutId: null | TimeoutId; /** * This flag is used to keep track of models that have been * forced to unload (regardless of the retain count). The force * unload happens via _forceUnload method and the only proper use * of that function is when the underlying data gets deleted while * the model is still active. e.g. when a table is deleted in the * main app while an instance of record_store is still alive. * NOTE: Once set to true, it never goes back to false. * * @internal */ _isForceUnloaded: boolean; /** @hidden */ constructor(sdk: Sdk, modelId: string); /** * Watching a key that needs to load data asynchronously will automatically * cause the data to be fetched. Once the data is available, the callback * will be called. * * @inheritdoc */ watch(keys: WatchableKey | ReadonlyArray, callback: FlowAnyFunction, context?: FlowAnyObject | null): Array; /** * Unwatching a key that needs to load data asynchronously will automatically * cause the data to be released. Once the data is available, the callback * will be called. * * @inheritdoc */ unwatch(keys: WatchableKey | ReadonlyArray, callback: FlowAnyFunction, context?: FlowAnyObject | null): Array; /** @inheritdoc */ get isDeleted(): boolean; /** */ get isDataLoaded(): boolean; /** @internal */ abstract _onChangeIsDataLoaded(): void; /** @internal */ abstract _loadDataAsync(): Promise>; /** @internal */ abstract _unloadData(): void; /** * Will cause all the async data to be fetched and retained. Every call to * `loadDataAsync` should have a matching call to `unloadData`. * * Returns a Promise that will resolve once the data is loaded. */ loadDataAsync(): Promise; /** */ unloadData(): void; _forceUnload(): void; _assertNotForceUnloaded(): void; } export default AbstractModelWithAsyncData;