@jsheaven/store
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@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

Package Sidebar

Install

npm i @jsheaven/store

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

15.5 kB

Total Files

12

Last publish

Collaborators

  • mansi1
  • kyr0