Skip to content

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 ParameterDefault type
TStateany
  • Store<TState>

new MobxAdapter<TState>(initialState, options?): MobxAdapter<TState>

Defined in: index.ts:40

ParameterType
initialStateTState
options?MobxAdapterOptions

MobxAdapter<TState>

dispatch(action): void

Defined in: index.ts:53

Dispatch an action to update state

ParameterType
actionAction

void

Store.dispatch


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.

any


getState(): TState

Defined in: index.ts:49

Get the current state

TState

Store.getState


subscribe(listener): () => void

Defined in: index.ts:73

Subscribe to state changes Returns an unsubscribe function

ParameterType
listener(state) => void

() => void

Store.subscribe