mirror of
https://github.com/Effect-TS/effect.git
synced 2026-12-04 03:35:36 +08:00
Co-authored-by: Giulio Canti <giulio.canti@gmail.com> Co-authored-by: Tim Smart <hello@timsmart.co> Co-authored-by: Effect Bot <tech-ops@effectful.co> Co-authored-by: Mattia Manzati <mattia.manzati@gmail.com>
32 lines
828 B
TypeScript
32 lines
828 B
TypeScript
/**
|
|
* Deno-backed `KeyValueStore` layers using Web Storage APIs.
|
|
*
|
|
* @stability unstable
|
|
* @since 4.0.0
|
|
*/
|
|
|
|
import type * as Layer from "effect/Layer"
|
|
import * as KeyValueStore from "effect/persistence/KeyValueStore"
|
|
|
|
/**
|
|
* Creates a `KeyValueStore` layer backed by `localStorage`, with values stored between sessions.
|
|
*
|
|
* @stability unstable
|
|
* @category layers
|
|
* @since 4.0.0
|
|
*/
|
|
export const layerLocalStorage: Layer.Layer<KeyValueStore.KeyValueStore> = KeyValueStore.layerStorage(() =>
|
|
localStorage
|
|
)
|
|
|
|
/**
|
|
* Creates a `KeyValueStore` layer backed by `sessionStorage`, with values stored only for the current session.
|
|
*
|
|
* @stability unstable
|
|
* @category layers
|
|
* @since 4.0.0
|
|
*/
|
|
export const layerSessionStorage: Layer.Layer<KeyValueStore.KeyValueStore> = KeyValueStore.layerStorage(() =>
|
|
sessionStorage
|
|
)
|