mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
fix: save persistent data
This commit is contained in:
1 parent
30e87743fc
commit
3846cbab4a
3 files changed
+8
-9
No files matched your search
Vendored
+2
-7
@@ -222,12 +222,7 @@
|
|||||||
"yolo",
|
"yolo",
|
||||||
"youtuber",
|
"youtuber",
|
||||||
"youtubers",
|
"youtubers",
|
||||||
"zoomable",
|
"zoomable"
|
||||||
"zustand"
|
|
||||||
],
|
],
|
||||||
"deno.enable": false,
|
"typescript.tsdk": "node_modules\\typescript\\lib"
|
||||||
"deno.unstable": false,
|
|
||||||
"cSpell.enableFiletypes": ["glsl", "proto3"],
|
|
||||||
"typescript.tsdk": "node_modules\\typescript\\lib",
|
|
||||||
"liveServer.settings.multiRootWorkspaceName": "blitzkit"
|
|
||||||
}
|
}
|
||||||
@@ -20,12 +20,17 @@ export class Varuna<Type, Arguments = void> {
|
|||||||
let data = initial;
|
let data = initial;
|
||||||
|
|
||||||
if (this.persistence && typeof localStorage !== "undefined") {
|
if (this.persistence && typeof localStorage !== "undefined") {
|
||||||
|
const instance = this;
|
||||||
const dehydrated = localStorage.getItem(this.persistence);
|
const dehydrated = localStorage.getItem(this.persistence);
|
||||||
|
|
||||||
if (dehydrated) {
|
if (dehydrated) {
|
||||||
const rehydrated = JSON.parse(dehydrated) as unknown;
|
const rehydrated = JSON.parse(dehydrated) as unknown;
|
||||||
data = merge(data, rehydrated);
|
data = merge(data, rehydrated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener("beforeunload", () => {
|
||||||
|
localStorage.setItem(this.persistence!, JSON.stringify(instance.state));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
|||||||
@@ -36,8 +36,7 @@
|
|||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-promise-suspense": "^0.3.4",
|
"react-promise-suspense": "^0.3.4",
|
||||||
"three": "^0.169.0",
|
"three": "^0.169.0",
|
||||||
"urlon": "^3.1.0",
|
"urlon": "^3.1.0"
|
||||||
"zustand": "^4.5.5"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/check": "^0.9.4",
|
"@astrojs/check": "^0.9.4",
|
||||||
|
|||||||
Reference in new issue
Block a user