Skip to main content

Type Alias: StateObservable<T>

StateObservable<T> = Observable<T> & object

Provides current configurator state through synchronous reads and subscriptions. Use getValue for a snapshot and subscribe for updates. The initial emission has the current newValue and no oldValue. Treat payloads as read-only and unsubscribe at teardown.

Type Parameters​

T​

T

Type Declaration​

getValue()​

getValue(): Nullable<T> | undefined

Reads the current value synchronously without subscribing. The observer’s own null and empty conventions apply. Undefined can mean the state is not yet available.

Returns​

Nullable<T> | undefined

Example​

const sku = window.mimeeqApp.observers.product.sku.getValue() ?? '';

Example​

const locale = window.mimeeqApp.observers.config.locale;
const current = locale.getValue();
const subscription = locale.subscribe(({ newValue, oldValue }) => console.log(oldValue, newValue));
window.addEventListener('pagehide', () => subscription.unsubscribe(), { once: true });