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/ObservableBoolean.md.

Class: ObservableBoolean

Beta

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

Constructors

Constructor

new ObservableBoolean(data, options?): ObservableBoolean

World Mutation Early Execution Beta

Parameters

data

boolean

The initial boolean value for this observable. 此可观察对象的初始布尔值。

options?

ObservableOptions

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

Returns

ObservableBoolean

Remarks

Creates a new ObservableBoolean with the provided initial boolean value. 使用提供的初始布尔值创建一个新的 ObservableBoolean

Methods

getData()

getData(): boolean

World Mutation Early Execution Beta

Returns

boolean

Remarks

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


setData()

setData(data): void

World Mutation Early Execution Beta

Parameters

data

boolean

The new boolean value to set. 要设置的新布尔值。

Returns

void

Remarks

Updates the boolean 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 boolean 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