@egt-ukraine/storage
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

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);
  }
}

Package Sidebar

Install

npm i @egt-ukraine/storage

Weekly Downloads

4

Version

1.3.1

License

MIT

Unpacked Size

92.1 kB

Total Files

27

Last publish

Collaborators

  • lehamotovilov
  • syperia
  • dimav
  • oleksandr.honcharov