Skip to content

ngrx-store-persist depends on @ngrx/store and angular 2+

Notifications You must be signed in to change notification settings

koriUA/rxjs-store-persist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

ngrx-store-persist depends on @ngrx/store and angular 2+

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published