IObservable | Matterport SDK
Usage of the SDK constitutes your agreement with the Matterport SDK Agreement. Email developers@matterport.com with any questions.

A data object that can have its changes observed via subscribing an IObserver or ObserverCallback or waited on for a specific condition to be met.

Type parameters

  • DataT

    The type of the data being observed.

Hierarchy

Index

Methods

subscribe

  • Subscribe to changes on this object. When this observable detects a change, the observer provided will be called with the data associated with this observable.

    // Example: subscribe to changes in the app state
    sdk.App.state.subscribe((appState) => {
      console.log(`App state changed to: ${appState.phase}`);
    });
    

    or:

    sdk.App.state.subscribe({
      onChanged(appState) {
        console.log(`App state changed to: ${appState.phase}`);
      }
    });
    

    Parameters

    Returns ISubscription

    A subscription that can be used to remove the subscribed observer.

waitUntil

  • Wait for a specific condition on this object to be met. When this observable detects a change, the condition provided will be called. When the condition returns true, the returned Promise will be resolved.

     // Example: pause execution of code until the app state is in the "playing" phase
     await sdk.App.state.waitUntil(
      appState => appState.phase == sdk.App.Phase.PLAYING
     );
    

    or:

    await sdk.App.state.waitUntil({
      waitUntil(appState) {
        return appState.phase == sdk.App.Phase.PLAYING;
      }
    });
    

    Parameters

    Returns Promise<DataT>

    A promise that is resolved when condition returns true.