WorkspaceLeaf.setViewState method
WorkspaceLeaf › setViewState
Shows a view of the given type in the leaf, building it throughApp.viewRegistry, exactly as Obsidian does.- **The view is only rebuilt when the type CHANGES.** A state naming the type the leaf already shows keeps the view and only calls
setState on it. - A registered type goes through its creator; a creator that throws is logged and falls back to the unknown-type view, which keeps the type it could not build. - An unregistered type gives the unknown-type view, except for 'empty', which gives WorkspaceLeaf._empty back — Obsidian's own answer for it. - A view that answers close on the result — a file view left with no file — sends the leaf back to the empty view; one that answers layout asks the workspace to update the layout. - active activates the leaf, group joins that leaf's link group, and the ephemeral state is applied last. - A call reached from inside another one is dropped, through Obsidian's own working guard.Obsidian also records navigation history around all of this; the mock has no history, so it does not.
Signature:
setViewState(viewState: ViewState, eState?: Record<string, unknown> | undefined): Promise<void>Parameters:
| Parameter | Type | Description |
|---|---|---|
| viewState | ViewState | The new view state. |
| eState? | Record<string, unknown> | undefined | The ephemeral state to apply along with it. |