
unissist
A tiny ~300b unistore persistence helper library state container with various storage adapters.
Table of Contents
Install
This project uses node and npm. Go check them out if you don't have them locally installed.
npm install --save unissist
Then with a module bundler like webpack or rollup, use as you would anything else:
import persistStore from 'unissist';
import localStorageAdapter from 'unissist/integrations/localStorageAdapter';
import indexedDBAdapter from 'unissist/integrations/indexdbAdapter';
import asyncStorageAdapter from 'unissist/integrations/asyncStorageAdapter';
The UMD build is also available on unpkg:
<script src="//unpkg.com/unistore/dist/unissist.umd.js"></script>
You can find the library on window.unissist
.
Usage
import createStore from 'unistore'
import persistStore from 'unissist'
import localStorageAdapter from 'unissist/integrations/localStorageAdapter';
const store = createStore({ count: 0 })
const adapter = localStorageAdapter();
persistStore(store, adapter);
Unissist also takes a third parameter that allows you to configure how your peristence works
import createStore from 'unistore'
import persistStore from 'unissist'
import localStorageAdapter from 'unissist/integrations/localStorageAdapter';
const store = createStore({ count: 0 })
const adapter = localStorageAdapter();
let config = {
version: 1,
debounceTime: 100,
migration: (oldState, oldversion) => ({ }),
map: state => ({ })
hydration: state => ({ })
}
persistStore(store, adapter, config);
Reporting Issues
Found a problem? Want a new feature? First of all, see if your issue or idea has already been reported.
If not, just open a new clear and descriptive issue.
Credits
Jason Miller for unistore, assign
util function, and a lot of the tooling that I stole used
Jake Archibald for idb-keyval where much of the code for the indexdbAdapter was stolen borrowed
Sean Groff for the name
License
MIT License © Donnie West