arbor-timetravel
Version:
Provides time traveling functionality to Arbor stores
45 lines (30 loc) • 1.31 kB
Markdown
Provides time traveling functionality to [Arbor](https://github.com/drborges/arbor-store) stores.
A simple Counter APP...
```js
import Arbor from "arbor-store"
import timetravel from "arbor-timetravel"
const store = timetravel(new Arbor({
todos: []
}))
// retrieves the current time cursor value
store.timeline.cursor
// goes back one time unit
store.timeline.travel.step(-1)
// move forward one time unit
store.timeline.travel.step(1)
// travels to a specific point in time
store.timeline.travel.to(5)
// goes back to the beginning of time
store.timeline.travel.origin()
// travels to the last state change (present)
store.timeline.travel.present()
```
Arbor leverages Structural Sharing in order to perform state mutations. A new
state tree is always created by applying the minimum amount of operations
necessary to generate the new state. With this, a series of state snapshots may
be recorded. This packages leverages that behavior in order to provide time
traveling features for Arbor based stores. Checkout [this proof of concept app](https://drborges.github.io/arbor-react-app) for more insights:
