EditorAtom

See source code
Table of contents

An Atom that is scoped to the lifetime of an Editor.

This is useful for storing UI state for tldraw applications. Keeping state scoped to an editor instead of stored in a global atom can prevent issues with state being shared between editors when navigating between pages, or when multiple editor instances are used on the same page.

class EditorAtom<T> {}

Constructor

Constructs a new instance of the EditorAtom class

Parameters

NameDescription

name

string

getInitialState

(editor: Editor) => T

Methods

get()

get(editor: Editor): T

Parameters

NameDescription

editor

Returns

T

getAtom()

getAtom(editor: Editor): Atom<T>

Parameters

NameDescription

editor

Returns

Atom<T>

set()

set(editor: Editor, state: T): T

Parameters

NameDescription

editor

state

T

Returns

T

update()

update(editor: Editor, update: (state: T) => T): T

Parameters

NameDescription

editor

update

(state: T) => T

Returns

T

Prev
Editor
Next
Ellipse2d