import type { MappingFunction } from '../types/mapping-function.type.js'; import type { MemoizationFunction } from '../types/memoization-function.type.js'; import { BehaviorSubject, type Observable } from '../../../external/rxjs/index.js'; /** * @class UmbBasicState * @description - State ensures the data is unique, not updating any Observes unless there is an actual change of the value using `===`. */ export declare class UmbBasicState { protected _subject: BehaviorSubject; constructor(initialData: T); /** * @function asObservable * @returns {Observable} Observable that the State casts to. * @description - Creates a new Observable with this State as the source. Observe this to subscribe to its value and future changes. * @example Example observe the data of a state * const myState = new UmbArrayState('Hello world'); * * this.observe(myState, (latestStateValue) => console.log("Value is: ", latestStateValue)); */ asObservable(): Observable; /** * @function asObservablePart * @param {(mappable: T) => R} mappingFunction - Method to return the part for this Observable to return. * @param {(previousResult: R, currentResult: R) => boolean} [memoizationFunction] - Method to compare if the data has changed. Should return true when data is identical. * @returns {Observable} * @description - Creates an Observable from this State that emits a derived value, deduplicated against its previous emission. */ asObservablePart(mappingFunction: MappingFunction, memoizationFunction?: MemoizationFunction): Observable; /** * @property {unknown} value - the value of the State. * @description - Holds the current data of this state. * @returns {unknown} Observable that * @example Example retrieve the current data of a state * const myState = new UmbArrayState('Hello world'); * console.log("Value is: ", myState.value); */ get value(): T; /** * @function getValue * @returns {unknown} The current data of this state. * @description - Provides the current data of this state. * @example Example retrieve the current data of a state * const myState = new UmbArrayState('Hello world'); * console.log("Value is: ", myState.value); */ getValue(): T; /** * @function destroy * @description - Destroys this state and completes all observations made to it. */ destroy(): void; /** * @function setValue * @param {unknown} data - The next data for this state to hold. * @description - Set the data of this state, if data is different than current this will trigger observations to update. * @example Example change the data of a state * const myState = new UmbArrayState('Good morning'); * // myState.value is equal 'Good morning'. * myState.setValue('Goodnight') * // myState.value is equal 'Goodnight'. */ setValue(data: T): void; }