Skip to content

rune-langium / visual-editor/src / createEditorStore

Function: createEditorStore()

ts
function createEditorStore(overrides?): UseBoundStore<Write<StoreApi<EditorStore>, {
  temporal: StoreApi;
}>>;

Defined in: packages/visual-editor/src/store/editor-store.ts:416

Create an isolated zustand editor store instance.

Parameters

ParameterTypeDescription
overrides?Partial<EditorState>Optional partial initial state to override defaults.

Returns

UseBoundStore<Write<StoreApi<EditorStore>, { temporal: StoreApi; }>>

A zustand useStore hook bound to the new isolated store.

Remarks

Returns a new zustand useStore hook bound to a fresh store instance. Use this when embedding multiple independent RuneTypeGraph components in the same React tree — each graph must own a separate store.

The store is wrapped with zundo temporal middleware for undo/redo support. Access undo/redo via useTemporalStore.

Use When

  • Rendering two or more RuneTypeGraph components simultaneously (different namespaces, split-pane editors, etc.)
  • Writing tests that need an isolated store per test case

Avoid When

  • You only need a single graph — use the pre-created useEditorStore singleton.

Pitfalls

  • Each createEditorStore() call allocates a new Zustand store + Zundo temporal tracker. Do NOT call this inside a render function — call once at module level or in a useState initializer.

Core packages released under MIT. Studio app released under FSL-1.1-ALv2.