Skip to content
/ store Public

A reactive, observed and auto-persisted object store

License

Notifications You must be signed in to change notification settings

jsheaven/store

Repository files navigation

@jsheaven/store

A reactive, observed and auto-persisted object store

User Stories

  1. As a developer, I want to have an object store simply persisted
  2. As a developer, I want to hook into changes at every depth reactively

Features

  • ✅ Offers the @jsheaven/observed reactive object API
  • ✅ Integrates with simply-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
  • ✅ Just 387 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

About

A reactive, observed and auto-persisted object store

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published