Socket
Socket
Sign inDemoInstall

ngrx-store-localstorage

Package Overview
Dependencies
9
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngrx-store-localstorage

State and local storage syncing for @ngrx/store


Version published
Weekly downloads
51K
increased by5.26%
Maintainers
1
Install size
43.5 kB
Created
Weekly downloads
 

Readme

Source

ngrx-store-localstorage

Simple syncing between ngrx store and local storage

Dependencies

ngrx-store-localstorage depends on @ngrx/store and Angular 2.

Usage

npm install ngrx-store-localstorage --save
  1. Configure your ngrx store as normal using provideStore.
  2. Using the provided localStorageMiddleware function, specify the slices of state you would like to keep synced with local storage.
  3. Optionally specify whether to rehydrate this state from local storage as initialState on application bootstrap.
import {bootstrap} from 'angular2/platform/browser';
import {TodoApp} from './todo-app';
import {provideStore} from "@ngrx/store";
import {localStorageMiddleware} from "ngrx-store-localstorage";

export function main() {
  return bootstrap(TodoApp, [
      provideStore({todos, visibilityFilter}),
      localStorageMiddleware(['todos', 'visibilityFilter'], true)
  ])
  .catch(err => console.error(err));
}

document.addEventListener('DOMContentLoaded', main);

API

localStorageMiddleware(keys : string[], rehydrateState : boolean = false)

Provide state (reducer) keys to sync with local storage. Optionally specify whether to rehydrate initialState from local storage on bootstrap.

Arguments
  • keys (string[]): State keys to sync with local storage
  • rehydrateState (boolean? = false): Pull initial state from local storage on startup

Keywords

FAQs

Last updated on 12 Mar 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc