Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

choo-persist

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

choo-persist

Synchronize choo state with indexedDB

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

choo-persist stability

npm version build status downloads js-standard-style

Synchronize choo state with localStorage

Usage

var persist = require('choo-persist')
var choo = require('choo')

var app = choo()
app.use(persist())

API

instance = persist([opts])

Create a new indexedDB database instance, and call the callback with the plugin when done. Can take an optional first argument of options:

  • opts.name: default 'app'; provide a name for the indexedDB database
  • opts.filter(state): modify the state that's about to be written to the IndexedDB database. Useful to strip values that cannot be serialized to IndexedDB.
var xtend = require('xtend')
var opts = {
  filter: function (state) {
    state = xtend(state) // clone the object
    delete state.sadArrayFilledWithFunctions
    return state
  }
}

Installation

$ npm install choo-persist

Should I use this while developing.

No; state is persisted between page reloads which might put your page in very odd states, with a very annoying way to clear. Consider using hot reloading for development instead.

How / when should I invalidate the database cache?

Ah, this is where good ol' data persistance comes into play - there's loads of approaches on this, but yeah you should def find a way to migrate data between incompatible models. Perhaps some day we'll have a good chapter on this in the choo handbook. Until then: have fun I guess?

License

MIT

Keywords

FAQs

Package last updated on 21 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc