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

Class: ObservableUIRawMessage

Beta

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

Constructors

Constructor

new ObservableUIRawMessage(data, options?): ObservableUIRawMessage

World Mutation Early Execution Beta

Parameters

data

UIRawMessage

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

options?

ObservableOptions

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

Returns

ObservableUIRawMessage

Remarks

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

Methods

getData()

getData(): UIRawMessage

World Mutation Early Execution Beta

Returns

UIRawMessage

Remarks

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


setData()

setData(data): void

World Mutation Early Execution Beta

Parameters

data

UIRawMessage

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

Returns

void

Remarks

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


subscribe()

subscribe(callback): (arg0) => void

World Mutation Early Execution Beta

Parameters

callback

(arg0) => void

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

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