ngrx-store-persist
TypeScript icon, indicating that this package has built-in type declarations

1.0.24 • Public • Published

ngrx-store-persist

Simple syncing between ngrx store and localStorage, IndexedDB or WebSQL.

Dependencies

ngrx-store-persist depends on @ngrx/store and Angular 2+.

Usage

npm install ngrx-store-persist --save
// main.ts
import { NgModule } from '@angular/core';
import {
  getAllDataFromLocalForage,
  default as localForage,
} from 'ngrx-store-persist';

getAllDataFromLocalForage({
  driver: localForage.INDEXEDDB,
  keys: [
    'user',
    'posts'
  ],
}).then(() => {
  platformBrowserDynamic()
    .bootstrapModule(AppModule)
    .catch(err => console.log(err));
});

Also need to add storageSyncMetaReducer to metaReducers:

// app.module.ts
import { storageSyncMetaReducer } from 'ngrx-store-persist';

StoreModule.forRoot(rootReducer, { metaReducers: [storageSyncMetaReducer] }),

##Config

  • keys (required) State keys to sync with storage.
  • driver (optional) by default equals localForage.LOCALSTORAGE. Also can be localForage.WEBSQL, localForage.INDEXEDDB.

Package Sidebar

Install

npm i ngrx-store-persist

Weekly Downloads

437

Version

1.0.24

License

ISC

Unpacked Size

30.3 kB

Total Files

18

Last publish

Collaborators

  • kori.if.ua