@minecraft/server-ui
    Preparing search index...

    Class Observable<T>Beta

    A class that represents data that can be Observed. Extensively used for UI.

    Type Parameters

    Index

    Constructors

    Methods

    • Beta

      Returns T

      Gets the data from the Observable.

    • Beta

      Parameters

      Returns Promise<string | TextFilteringError[]>

      Gets filtered data from the Observable (only available for strings). In case of failure, it will return an array of TextFilteringError that can provide more context about the filtering process. For testing purposes, the options are available under "Creator -> Text Filtering" settings menu. This delay is only applied to the getFilteredText function and can be used to simulate network latency when testing.

    • Beta

      Parameters

      • data: T

      Returns void

      Sets the data on this Observable and notifies the subscribers.

    • Beta

      Parameters

      • listener: (newValue: T) => void

      Returns (newValue: T) => void

      Subscribes a callback to any changes that occur to the Observable. The return value can be passed into the unsubscribe function to stop listening to changes.

    • Beta

      Returns unknown

    • Beta

      Parameters

      • listener: (newValue: T) => void

      Returns void

      Unsubscribe a callback from any changes that occur to the Observable. This takes the return value from the subscribe function.