@egt-ukraine/storage

Angular wrapper for [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage), [sessionStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage).

Stats

StarsIssuesVersionUpdatedCreatedSize
@egt-ukraine/storage
1.3.16 months ago4 years agoMinified + gzip package size for @egt-ukraine/storage in KB

Readme

EGT Storage Module

Angular wrapper for localStorage, sessionStorage.

How to use?

Install:

npm i @egt-ukraine/storage or yarn add @egt-ukraine/storage

import { NgModule } from '@angular/core';

import { StorageModule } from '@egt-ukraine/storage';

@NgModule({
  imports: [
    StorageModule.forRoot(),
  ],
  exports: [],
  declarations: [],
})
export class CoreModule {}

Usage:

import { Injectable } from '@angular/core';

import { IWindowStorage, StorageRegistry } from '@egt-ukraine/storage';

@Injectable()
export class SomeService {
  private _storage: IWindowStorage;
  private _storageObjectKey: string = 'my-cool-variable-from-local-storage';
  private _storageType: string = 'local';

  constructor(private _storageRegistry: StorageRegistry) {
    this._storage = this._storageRegistry.getStorage(this._storageType);
  }

  public setSomeValue(someValue: string): void {
    this._storage.set(this._storageObjectKey, someValue);
  }

  public getSomeValue(): string {
    return this._storage.get(this._storageObjectKey);
  }
}

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.