import type { dh } from '@deephaven/jsapi-types'; import { type UriVariableDescriptor } from './useObjectFetcher'; /** Function for unsubscribing from a given subscription */ export type UnsubscribeFunction = () => void; /** Update when the ObjectFetch is still loading */ export type ObjectFetchLoading = { status: 'loading'; }; /** Update when the ObjectFetch has errored */ export type ObjectFetchError = { error: NonNullable; status: 'error'; }; /** Update when the object is ready */ export type ObjectFetchReady = { fetch: () => Promise; status: 'ready'; }; /** * Update with the current `fetch` function and status of the object. * - If both `fetch` and `error` are `null`, it is still loading the fetcher * - If `fetch` is not `null`, the object is ready to be fetched * - If `error` is not `null`, there was an error loading the object */ export type ObjectFetchUpdate = ObjectFetchLoading | ObjectFetchError | ObjectFetchReady; export type ObjectFetchUpdateCallback = (update: ObjectFetchUpdate) => void; /** ObjectFetchManager for managing a subscription to an object using a VariableDescriptor */ export type ObjectFetchManager = { /** * Subscribe to the fetch function for an object using a variable descriptor. * It's possible that the fetch function changes over time, due to disconnection/reconnection, starting/stopping of applications that the object may be associated with, etc. * * @param descriptor Descriptor object or URI of the object to fetch. Can be extended by a specific implementation to include more details necessary for the ObjectManager. * @param onUpdate Callback function to be called when the object is updated. * @returns An unsubscribe function to stop listening for fetch updates and clean up the object. */ subscribe: (descriptor: dh.ide.VariableDescriptor | UriVariableDescriptor, onUpdate: ObjectFetchUpdateCallback) => UnsubscribeFunction; }; /** Context for tracking an implementation of the ObjectFetchManager. */ export declare const ObjectFetchManagerContext: import("react").Context; /** * Retrieve a `fetch` function for the given variable descriptor. * * @param descriptor Descriptor or URI to get the `fetch` function for * @returns An object with the current `fetch` function, OR an error status set if there was an issue fetching the object. * Retrying is left up to the ObjectManager implementation used from this context. */ export declare function useObjectFetch(descriptor: dh.ide.VariableDescriptor | UriVariableDescriptor): ObjectFetchUpdate; //# sourceMappingURL=useObjectFetch.d.ts.map