ng-simple-storage
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

ng-simpe-storage

This library is a simple wrapper on a localStorage

Installation

Run npm install --save ng-simple-storage

API reference for ng-simple-storage

import { StorageService } from 'ng-simple-storage

Services

StorageService

Properties

length: number - Currently storred items count

items: { key: value } - Currently storred items

onItemChange: Observable<StorageItemChangeEvent> - Observable which fires when item in storage changes

Methods

clear(): void - clear storage

getItem<Type>(key: string): Type - return item by key

removeItem<Type>(key: string): void - remove item by key

key(index: number): string - return the key of item at the specified index

setItem<Type>(key: string, value: Type): void - save item with a specified key

setStorage(storage: Storage): void - change storage used by the service

Aditional classes

StorageItemChangeEvent<T>

Properties

key: string - key of changed item

oldValue: T - value of item before event emitted

newValue: T - current value of item

Setting custom storage

You can provide your own implementation of storage by

{ provide: DEFAULT_STORAGE, useValue: CustomStorage }

CustomStorage must implement Storage interface

Readme

Keywords

Package Sidebar

Install

npm i ng-simple-storage

Weekly Downloads

6

Version

1.0.1

License

MIT

Last publish

Collaborators

  • tishinanton