Open History to see the last commit
1/**
2 * Deno-backed `KeyValueStore` layers using Web Storage APIs.
3 *
4 * @stability unstable
5 * @since 4.0.0
6 */
7
8import type * as Layer from "effect/Layer"
9import * as KeyValueStore from "effect/persistence/KeyValueStore"
10
11/**
12 * Creates a `KeyValueStore` layer backed by `localStorage`, with values stored between sessions.
13 *
14 * @stability unstable
15 * @category layers
16 * @since 4.0.0
17 */
18export const layerLocalStorage: Layer.Layer<KeyValueStore.KeyValueStore> = KeyValueStore.layerStorage(() =>
19 localStorage
20)
21
22/**
23 * Creates a `KeyValueStore` layer backed by `sessionStorage`, with values stored only for the current session.
24 *
25 * @stability unstable
26 * @category layers
27 * @since 4.0.0
28 */
29export const layerSessionStorage: Layer.Layer<KeyValueStore.KeyValueStore> = KeyValueStore.layerStorage(() =>
30 sessionStorage
31)