MobxAdapter
Defined in: index.ts:35
MobX adapter — wraps state in an observable.box. Dispatched actions are
applied via applyAction and committed inside runInAction so MobX’s
strict-mode (enforceActions: 'always') is respected by default.
The box uses { deep: false } because state replacement is immutable
(whole-reference swap on every dispatch); deep observability would fight
the immutable model.
getBox() exposes the underlying IObservableValue<TState> so consumers
can attach MobX-native primitives — autorun, reaction, computed,
mobx-react observer — on the same backing observable that drives
useStore / useDispatch from @input-actions/core.
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 MobxAdapter<
TState>(initialState,options?):MobxAdapter<TState>
Defined in: index.ts:40
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
initialState | TState |
options? | MobxAdapterOptions |
Returns
Section titled “Returns”MobxAdapter<TState>
Methods
Section titled “Methods”dispatch()
Section titled “dispatch()”dispatch(
action):void
Defined in: index.ts:53
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
getBox()
Section titled “getBox()”getBox():
any
Defined in: index.ts:89
Adapter-specific extension: the underlying MobX observable.box.
Use it with autorun(() => log(box.get())), reaction(() => box.get(), fn),
computed(() => derive(box.get())), mobx-react observer, etc. — all of
which run on the same backing observable as the action-driven state.
Returns
Section titled “Returns”any
getState()
Section titled “getState()”getState():
TState
Defined in: index.ts:49
Get the current state
Returns
Section titled “Returns”TState
Implementation of
Section titled “Implementation of”Store.getState
subscribe()
Section titled “subscribe()”subscribe(
listener): () =>void
Defined in: index.ts:73
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