For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /server-ui/classes/ObservableNumber.md.

Class: ObservableNumber

Beta

An observable that holds a numeric value. Listeners are notified whenever the value changes. 一个持有数值的可观察对象。当值发生变化时,会通知所有监听器。

Constructors

Constructor

new ObservableNumber(data, options?): ObservableNumber

World Mutation Early Execution Beta

Parameters

data

number

The initial numeric value for this observable. 此可观察对象的初始数值。

options?

ObservableOptions

Optional configuration for the observable, such as whether the value can be written by the client. 可观察对象的可选配置,例如该值是否可由客户端写入。

Returns

ObservableNumber

Remarks

Creates a new ObservableNumber with the provided initial numeric value. 使用提供的初始数值创建一个新的 ObservableNumber

Methods

getData()

getData(): number

World Mutation Early Execution Beta

Returns

number

Remarks

Returns the current numeric value held by this observable. 返回此可观察对象持有的当前数值。


setData()

setData(data): void

World Mutation Early Execution Beta

Parameters

data

number

The new numeric value to set. 要设置的新数值。

Returns

void

Remarks

Updates the numeric value held by this observable. If the new value differs from the current value, all subscribed listeners are notified with the new value. 更新此可观察对象持有的数值。如果新值与当前值不同,则会使用新值通知所有已订阅的监听器。


subscribe()

subscribe(callback): (arg0) => void

World Mutation Early Execution Beta

Parameters

callback

(arg0) => void

A function that receives the new numeric value each time the observable changes. 每次可观察对象发生变化时接收新数值的函数。

Returns

(arg0) => void

Remarks

Registers a callback to be invoked whenever the observable's value changes. Returns the callback, which can be passed to unsubscribe to remove the listener. 注册一个回调函数,当可观察对象的值发生变化时调用。返回该回调函数,可将其传递给 unsubscribe 以移除监听器。


unsubscribe()

unsubscribe(callback): boolean

World Mutation Early Execution Beta

Parameters

callback

(arg0) => void

The callback handle previously returned by subscribe. 先前由 subscribe 返回的回调句柄。

Returns

boolean

Remarks

Removes a previously registered listener from this observable. Returns true if the listener was found and removed, false if it was not found. 从此可观察对象中移除先前注册的监听器。如果找到并移除了监听器,则返回 true;如果未找到,则返回 false