DrSensor / DrSensor/nusa

Resumability a.k.a data snapshot

Open
#15 1 comment 0 reactions 0 assignees View on GitHub
data binding enhancement priority: medium
Dominant language
JavaScript
Stars
4
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Not to be confused with [Qwik Resumability](https://qwik.builder.io/docs/concepts/resumable/#application-state) 😅

Well, the idea is that all changes in class ~~property~~ accessor will write the data into a snapshot. The snapshot is stored into persisted medium either at [debounced](https://rxjs.dev/api/index/function/debounceTime) eventful write or at regular interval when in [@frameloop](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame). To avoid the cost of serialization, the change should be incremental. Storing the snapshot should only cost ~~concatenation + casting the value into string (or maybe TLV format)~~ nothing! (thanks to [structuredClone()](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone) algorithm in IndexedDB). The real cost is when you load then parse the snapshot at startup.

```html

```

This bring several benefits:
1. No need for hot reloading the ES Module (bye-bye webpack and vite 👋). You just need to reload the page.
2. ~~Save game state as html. The experience might be similar with "Quick save states" in Gameboy emulator.~~ not possible since it only stored in IndexedDB
3. State synchronization across client<->client or clients<->server. ~~This is similar on how ECS being utilized in multiplayer game. However, it only need the snapshot, no need to store that snapshot into persisted medium.~~ Most likely has similar approach on how PouchDB replication works.

Relevant:
- #40

**~~TODO~~**
~~- [ ] implement `class IncrementalJsonWriter extends Map`~~
~~- [ ] implement generic snapshot (possible medium: localStorage, sessionStorage, inline inside html page)~~

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.