1.0.1 • Published 7 years ago

ng-simple-storage v1.0.1

Weekly downloads
12
License
MIT
Repository
github
Last release
7 years ago

ng-simpe-storage

This library is a simple wrapper on a localStorage

Demo

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

1.0.1

7 years ago

1.0.0

7 years ago

0.0.0-beta.6

7 years ago

0.0.0-beta.5

7 years ago

0.0.0-beta.4

7 years ago

0.0.0-beta.3

7 years ago

0.0.0-beta.2

7 years ago

0.0.0-beta.1

7 years ago

0.0.0-beta.0

7 years ago