0.0.19 • Published 2 years ago
@shared-state/persist v0.0.19
@shared-state/persist
此软件包提供状态持久化功能
快速开始
Install @shared-state/core
and @shared-state/persist
pnpm install @shared-state/core @shared-state/persist
示例
使用 localStorage 或 sessionStorage 持久化状态
import { createSharedState } from "@shared-state/core";
import { persist, createWebPersistentStorage } from "@shared-state/persist";
const localStoragePersistentState = persist(createSharedState(0), {
key: "localStorage",
storage: createWebPersistentStorage(localStorage),
});
const sessionStoragePersistentState = persist(createSharedState(0), {
key: "sessionStorage",
storage: createWebPersistentStorage(sessionStorage),
});
监听持久化数据加载状态
import { createSharedState } from "@shared-state/core";
import { persist, createWebPersistentStorage } from "@shared-state/persist";
const persistentState = persist(createSharedState(0), {
key: "localStorage",
storage: createWebPersistentStorage(localStorage),
});
persistentState.hydrationState.subscribe((hydrating) => console.log(hydrating));
0.0.18
2 years ago
0.0.19
2 years ago
0.0.10
2 years ago
0.0.11
2 years ago
0.0.12
2 years ago
0.0.13
2 years ago
0.0.14
2 years ago
0.0.15
2 years ago
0.0.9
2 years ago
0.0.16
2 years ago
0.0.8
2 years ago
0.0.17
2 years ago
0.0.5
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.4
2 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago