ngrx-sync-local-storage
v11.2.16
Published
Extensions sync state to local storage
Downloads
9
Readme
ngrx-sync-local-storage
Extensions sync state to local storage
Compatibility
ngrx-sync-local-storage | Angular ------------------------|-------- 12.x.x | 12.x.x 11.x.x | 11.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]