@jsheaven/store
A reactive, observed and auto-persisted object store
User Stories
- As a developer, I want to have an object store simply persisted
- As a developer, I want to hook into changes at every depth reactively
Features
✅ Offers the@jsheaven/observed
reactive object API✅ Integrates withsimply-persist
to save on any change✅ Middleware function API allows to hook what is read and written (e.g. for encryption)✅ Available as a simple API✅ Just387 byte
nano sized (ESM, gizpped)✅ Tree-shakable and side-effect free✅ Runs on Windows, Mac, Linux, CI tested✅ First class TypeScript support✅ 100% Unit Test coverage
Example usage
Setup
- yarn:
yarn add @jsheaven/store
- npm:
npm install @jsheaven/store
ESM
import { store } from '@jsheaven/store'
export interface MyStore {
a: boolean
b: number
c: {
foo: string
}
}
const myStore = await store<MyStore>({
name: 'myStore',
initialValue: { a: true, b: 1, c: { foo: 'nice!' }} },
provider: 'session' // from `simply-persist`; persists to SessionStorage
})
CommonJS
const { store } = require('@jsheaven/store')
// same API like ESM variant