Skip to main content

View.Layer

Extends: IObservable<View.Layer>

Properties

Measurements

Measurements: Omit<View.Measurements, 'MeasurementType' | 'getData' | 'data' | 'toggleMode' | 'mode'>

Tag

Tag: Omit<View.Tag, 'AttachmentType' | 'attachments' | 'data' | 'openTags' | 'close' | 'dock' | 'open' | 'registerAttachment' | 'registerSandbox' | 'toggleDocking' | 'toggleNavControls' | 'toggleSharing'>

A subset of the Tag namespace's functionality to manipulate Tags on this layer.

Provides access to Tag mutations including Tag.add to add directly to a layer.

Does not include observables or enums.

Accessors

common

common: (readonly) boolean

Whether this layer is common (shared across all views)

id

id: (readonly) string

The unique id of the Layer

name

name: (readonly) string

The human-readable name of the Layer

toggled

toggled: (readonly) boolean

Whether this Layer toggled on or off. If toggled off, this Layer's objects are hidden.

type

type: (readonly) LayerType

The type of layer

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}`);
}
});
ParameterType
observerIObserver<View.Layer> | ObserverCallback<View.Layer>
an observer or callback to receive change notifications

Returns: ISubscription

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

toggle

toggle(active?: boolean): Promise<void>

Toggle this Layer's state to active.

ParameterType
active?boolean
Whether this Layer should be toggled on or off. If active is undefined, the state is flipped.

Returns: Promise<void>

waitUntil

waitUntil(condition: ICondition<View.Layer> | ConditionCallback<View.Layer>): Promise<View.Layer>

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;
}
});
ParameterType
conditionICondition<View.Layer> | ConditionCallback<View.Layer>
a condition or callback that returns true when the desired state is met

Returns: Promise<View.Layer>

A promise that is resolved when condition returns true.