ng-simple-storage v1.0.1
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
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago