11.2.16 • Published 3 years ago

ngrx-sync-local-storage v11.2.16

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

ngrx-sync-local-storage

Extensions sync state to local storage

Compatibility

ngrx-sync-local-storageAngular
12.x.x12.x.x
11.x.x11.x.x

Get started

1. Update AppComponent

import {NgrxSyncLocalStorageService} from "ngrx-sync-local-storage";
@Component()
export class AppComponent implements OnInit {

  constructor(
    private readonly renderer: Renderer2,
    private readonly store: Store<State>,
    private sync: NgrxSyncLocalStorageService
  ) {
  }

  ngOnInit() {
    this.sync.listenStorage(this.renderer, this.store);
  }

}

2. update AppModule

import {NgrxSyncLocalStorageModule} from "ngrx-sync-local-storage";

@NgModule({
 
  imports: [
   
    NgrxSyncLocalStorageModule
  ],
 
})
export class AppModule {
}

3. Update meta reducer

import {localStorageSyncReducer} from 'ngrx-sync-local-storage';

export function addLocalStorageSyncReducer(reducer: ActionReducer<any>): ActionReducer<any> {
  return localStorageSyncReducer(reducer, ['todos']);
}

export const metaReducers: MetaReducer<AppState>[] = [addLocalStorageSyncReducer]
11.2.16

3 years ago

11.2.15

3 years ago

11.2.14

3 years ago

12.0.1

3 years ago