Skip to content
⚠️The API is still evolving — breaking changes are possible before the first stable release.

obs

Deprecated

obs() is deprecated. Use enableObservableTracking() instead — it makes all MobX reads reactive inside Solid computations and JSX, so obs() is unnecessary. obs() will be removed in the first release.

ts
function obs<T>(getter: () => T): Accessor<T>

Converts a MobX observable expression into a SolidJS signal accessor.

Useful when you want to bridge a single MobX value into Solid without calling enableObservableTracking().

Parameters

NameTypeDescription
getter() => TFunction that reads an observable value

Returns

A SolidJS Accessor<T> that updates when the observable expression changes.

Example

tsx
import { obs } from "mobx-solid";

const count = obs(() => store.count);
// count() is a SolidJS accessor that updates when store.count changes

function Counter() {
  return <div>{count()}</div>;
}

Notes

  • Internally uses MobX autorun and a Solid createSignal with equals: false.
  • The autorun is disposed via Solid onCleanup when the owning reactive scope is cleaned up.
  • If enableObservableTracking() is already enabled, you usually do not need this — read MobX observables directly inside Solid computations and JSX.