Skip to content

WorkspaceLayoutStateKey<T>

A typed handle to one layout-scoped key.

Every method takes an optional leaf. Without one, the value belongs to the whole layout (the workspace scope).

Import:

import type { WorkspaceLayoutStateKey } from '@mnaoumov/obsidian-lib/components/workspace-layout-state-component';

Signature:

export interface WorkspaceLayoutStateKey<T>

Properties

PropertyTypeDescription
get(leaf?: WorkspaceLeaf) => TReads the value: a clone of the stored one, or of the default when nothing is stored or the stored value fails the key's guard.
has(leaf?: WorkspaceLeaf) => booleanChecks whether a value is stored, valid or not.
keystringThe key name, unique within the plugin.
onChange(callback: (change: WorkspaceLayoutStateChange<T>) => void) => () => voidSubscribes to changes of this key made through set or unset, in any scope and from any copy of the library. A layout load is reported through WorkspaceLayoutStateComponent.onLayoutLoad instead.
set(value: T, leaf?: WorkspaceLeaf) => voidStores a clone of the value and requests a layout save. Storing a value equal to the stored one does nothing.
unset(leaf?: WorkspaceLeaf) => voidRemoves the stored value, so get reads the default again, and requests a layout save.

Links to this page: