https://github.com/oelin/ixy
A reversible event store.
https://github.com/oelin/ixy
events state-management time-travel
Last synced: 4 months ago
JSON representation
A reversible event store.
- Host: GitHub
- URL: https://github.com/oelin/ixy
- Owner: oelin
- License: mit
- Created: 2023-02-17T14:02:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-28T10:32:45.000Z (over 1 year ago)
- Last Synced: 2025-03-12T05:32:48.629Z (7 months ago)
- Topics: events, state-management, time-travel
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ixy
A reversible event store.
This package aims to provide a bidirectional event-based state management system which supports timeline recomputation. This allows applications to change past actions while ensuring future state is affected in a predictable way. Useful for turn-based games or other applications where previous actions can be changed.
```js
const store = new Store((state, action) => {
if (action === 'increment') return state + 1
if (action === 'decrement') return state - 1
}
)
```Perform actions.
```js
store.push('increment') // 1
store.push('increment') // 2
store.push('decrement') // 1
```Move forwards or backwards in time.
```js
store.reverse() // 2
store.forward() // 1
```Change prior actions and recompute the timeline deterministically.
```js
store.replace(0, 'decrement') // Set the initial action to `decrement` instead of `increment`.
// The new timeline is 0 -> 1 -> 0
```