UNPKG

@dhmk/atom

Version:

Lightweight mobx-like observable values, computed values and side-effects

12 lines (11 loc) 373 B
import observableObject from "./object"; import observableArray from "./array"; export default function observable(x) { if (Array.isArray(x)) return observableArray(x.map(observable)); if (x && typeof x === "object" && Object.getPrototypeOf(x) === Object.prototype) return observableObject(x, observable); return x; }