import type { UmbContextCallback, UmbContextConsumerAsPromiseOptionsType, UmbContextConsumerController, UmbContextMinimal, UmbContextProviderController, UmbContextToken } from '../context-api/index.js'; import type { UmbControllerAlias, UmbControllerHost } from '../controller-api/index.js'; import type { ObserverCallback, UmbObserverController } from '../observable-api/index.js'; import type { Observable } from '../../external/rxjs/index.js'; export interface UmbClassGetContextOptions extends UmbContextConsumerAsPromiseOptionsType { skipHost?: boolean; passContextAliasMatches?: boolean; } export interface UmbClassInterface extends UmbControllerHost { /** * @description Observe an Observable. An Observable is a declared source of data that can be observed. An observables is declared from a UmbState. * @param {Observable} source An Observable to observe from. * @param {ObserverCallback | undefined} callback Callback method called when data is changed. * @param {UmbControllerAlias | null | undefined} controllerAlias Define an explicit controller alias. If not defined then one will be generated based on the callback function. If null is parsed no controller alias will be given. * @returns {UmbObserverController} Reference to the created Observer Controller instance. * @memberof UmbClassInterface */ observe | undefined, T, SpecificT = ObservableType extends Observable ? ObservableType extends undefined ? U | undefined : U : undefined, SpecificR = ObservableType extends undefined ? UmbObserverController | undefined : UmbObserverController>(source: ObservableType, callback?: ObserverCallback, controllerAlias?: UmbControllerAlias | null): SpecificR; /** * @description Provide a context API for this or child elements. * @param {string} alias * @param {instance} instance The API instance to be exposed. * @returns {UmbContextProviderController} Reference to the created Context Provider Controller instance * @memberof UmbClassInterface */ provideContext(alias: string | UmbContextToken, instance: R): UmbContextProviderController; /** * @description Subscribe to a context. The callback fires when the context resolves, again if the context is replaced, and can also be invoked with `undefined` if the context is unprovided or the host disconnects. Use this whenever a controller or element needs the context at setup time — both for ongoing observation and for reading values immediately on resolve. This is the default choice; prefer it over `getContext` unless the context is only needed inside a later user action. * @param {string} alias * @param {UmbContextCallback} callback Callback method called with the resolved context instance or `undefined`. * @returns {UmbContextConsumerController} Reference to the created Context Consumer Controller instance * @memberof UmbClassInterface */ consumeContext(alias: string | UmbContextToken, callback: UmbContextCallback): UmbContextConsumerController; /** * @description Retrieve a context once as a Promise. Use this only when the context is first needed inside a user action or event handler that runs later (for example a button click, a property action, or an entity action `execute()`). For setup-time access — including a single immediate read — use `consumeContext` instead so the controller lifecycle handles resolution and cleanup. The returned Promise may reject if the context is not found before the default timeout; callers should handle rejection and/or pass `preventTimeout` in the options when waiting longer is expected. * @param {string} alias * @param {UmbClassGetContextOptions} [options] Options for resolving the context once, including timeout-related behavior such as `preventTimeout`. * @returns {Promise} A Promise resolving to the Context API instance when available, or `undefined` when applicable. * @memberof UmbClassInterface */ getContext(alias: string | UmbContextToken, options?: UmbClassGetContextOptions): Promise; }