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

mobx-state-tree-localstorage

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-state-tree-localstorage

[![npm version](https://badge.fury.io/js/mobx-state-tree-localstorage.svg)](https://badge.fury.io/js/mobx-state-tree-localstorage) [![CircleCI](https://circleci.com/gh/isaachinman/mobx-state-tree-localstorage.svg?style=shield)](https://circleci.com/gh/isa

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
167
decreased by-39.49%
Maintainers
1
Weekly downloads
 
Created
Source

mobx-state-tree-localstorage

npm version CircleCI

Persist your mobx-state-tree stores in localStorage

What is this?

mobx-state-tree-localstorage is a helper package, which allows you to easily persist your mob-state-tree stores in localStorage.

Setup

1. Installation

yarn add mobx-state-tree-localstorage

You need to also have mobx and mobx-state-tree installed.

2. Usage

Instead of calling model.create(), pass it into the persistInLocalStorage function, which will persist the tree in localStorage, and also return the created model:

// Change this
const store = Store.create({
    todos: [
        {
            title: "Get coffee"
        }
    ]
})

// To this
const store = persistInLocalStorage({
  tree: Store,
  id: '@myapp/TodoStore',
  initialState: {
    todos: [
        {
            title: "Get coffee"
        }
    ]
  }
})

Config Options

KeyExplanation
treeA mobx-state-tree model
idA string ID which will be used to get/set the tree in localStorage
initialStateThe initial state for your store
blacklistKeysAny top-level keys for your store which you don't want to persist in localStorage

FAQs

Package last updated on 09 May 2020

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