There is no native way to:
track changes over time inspect previous values debug state transitions replay or revert changes Motivation
Modern applications require observability of state changes for:
debugging complex applications (React, Node.js, backend systems) audit logging in enterprise systems time-travel debugging (Redux DevTools-style tools) reactive programming models
Currently, developers rely on:
Proxy wrappers Redux / MobX / Zustand custom logging systems
This leads to inconsistent APIs and repeated implementation effort.
Proposed Solution
Introduce a built-in Observable API for state tracking.
API Design
-
Create observable state const user = Observable.state({ name: "Ali" });
-
Mutations are tracked automatically user.name = "Ahmed"; user.name = "Sara";
-
Access history user.history();
Returns:
[ { path: "name", from: "Ali", to: "Ahmed", timestamp: 1710001 }, { path: "name", from: "Ahmed", to: "Sara", timestamp: 1710002 } ] 4. Undo / Redo user.undo(); user.redo(); 5. Snapshot & restore const snapshot = user.snapshot();
user.restore(snapshot); 6. Configuration const user = Observable.state({ name: "Ali" }, { deep: true, maxHistory: 100, retention: "ring-buffer" }); Examples Example 1: Basic usage const counter = Observable.state({ value: 0 });