import type { ObservableValue, ValueChangeCallback } from './observable-value.js' export type ValueObserverOptions = { filter?: (nextValue: T, lastValue: T) => boolean } /** * Subscription handle returned by {@link ObservableValue.subscribe}. Disposing * the observer unsubscribes the callback from the observable; disposing the * underlying {@link ObservableValue} drops every observer and renders all * existing handles inert. */ export class ValueObserver implements Disposable { public [Symbol.dispose]() { this.observable.unsubscribe(this) } constructor( public readonly observable: ObservableValue, public callback: ValueChangeCallback, public readonly options?: ValueObserverOptions, ) {} }