ThingAdapter
Defined in: index.ts:35
thi.ng/atom adapter — backs state with @thi.ng/atom’s Atom<T>. When
options.history is set, the atom is wrapped in History and the
adapter exposes undo / redo / canUndo / canRedo / clearHistory.
Returned by createThingStoreSync / createThingStore as the concrete adapter type so consumers
can access undo/redo without a cast. Still implements Store<T> — works
anywhere the other adapters do.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
TState | any |
Implements
Section titled “Implements”Store<TState>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ThingAdapter<
TState>(initialState,options?):ThingAdapter<TState>
Defined in: index.ts:42
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
initialState | TState |
options? | ThingAdapterOptions |
Returns
Section titled “Returns”ThingAdapter<TState>
Methods
Section titled “Methods”canRedo()
Section titled “canRedo()”canRedo():
boolean
Defined in: index.ts:113
Returns
Section titled “Returns”boolean
canUndo()
Section titled “canUndo()”canUndo():
boolean
Defined in: index.ts:109
Returns
Section titled “Returns”boolean
clearHistory()
Section titled “clearHistory()”clearHistory():
void
Defined in: index.ts:122
Empty the undo and redo stacks. State is unchanged, so subscribers are
not notified: a component showing canUndo() / canRedo() has to
re-render itself after calling this.
Returns
Section titled “Returns”void
dispatch()
Section titled “dispatch()”dispatch(
action):void
Defined in: index.ts:67
Dispatch an action to update state
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
action | Action |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Store.dispatch
getState()
Section titled “getState()”getState():
TState
Defined in: index.ts:63
Get the current state
Returns
Section titled “Returns”TState
Implementation of
Section titled “Implementation of”Store.getState
redo()
Section titled “redo()”redo():
TState|undefined
Defined in: index.ts:105
Returns
Section titled “Returns”TState | undefined
subscribe()
Section titled “subscribe()”subscribe(
listener): () =>void
Defined in: index.ts:86
Subscribe to state changes Returns an unsubscribe function
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
listener | (state) => void |
Returns
Section titled “Returns”() => void
Implementation of
Section titled “Implementation of”Store.subscribe
undo()
Section titled “undo()”undo():
TState|undefined
Defined in: index.ts:101
Returns
Section titled “Returns”TState | undefined