https://github.com/unyt-org/example-history-api
A example project to showcase the DATEX history API
https://github.com/unyt-org/example-history-api
datex pointers typescript uix uix-example unyt
Last synced: 1 day ago
JSON representation
A example project to showcase the DATEX history API
- Host: GitHub
- URL: https://github.com/unyt-org/example-history-api
- Owner: unyt-org
- License: mit
- Created: 2024-04-04T11:46:29.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-21T19:43:35.000Z (about 1 year ago)
- Last Synced: 2026-01-15T21:38:29.809Z (4 months ago)
- Topics: datex, pointers, typescript, uix, uix-example, unyt
- Language: TypeScript
- Homepage: https://history.example.unyt.org
- Size: 11.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DATEX History API Example
This is a example project demonstrating how to use the
[History API](https://docs.unyt.org/manual/datex/history) of DATEX. The API
provides a way to undo and redo state changes of one or multiple pointers.
## Usage
The history for a pointer can be managed by creating a new History object and
adding the pointer to the history:
```ts
import { History } from "datex-core-legacy/utils/history.ts";
const entries = $$([]);
const history = new History();
history.add(entries);
```
Now, every state change of the entries array is recorded and can be undone or
repeated:
```ts
entries.push("Entry 1");
entries.push("Entry 2");
entries.push("Entry 3");
console.log(entries); // ["Entry 1", "Entry 2", "Entry 3"]
// undo last change
history.back();
console.log(entries); // ["Entry 1", "Entry 2"]
// undo second last change
history.back();
console.log(entries); // ["Entry 1"]
// repeat second last change
history.forward();
console.log(entries); // ["Entry 1", "Entry 2"]
```
---
© unyt 2025 • [unyt.org](https://unyt.org)