docs(): LocalStorage

This commit is contained in:
mhartington
2015-12-16 15:52:32 -05:00
parent 67f0d3c7dd
commit a8a88649c2

View File

@@ -2,6 +2,8 @@ import {StorageEngine} from './storage';
/**
* @name LocalStorage
* @description
* The LocalStorage storage engine uses the browser's local storage system for
* storing key/value pairs.
*
@@ -10,6 +12,20 @@ import {StorageEngine} from './storage';
* by the operating system (iOS).
*
* For guaranteed, long-term storage, use the SqlStorage engine which stores data in a file.
*
* @usage
* ```ts
* import {Page, Storage, LocalStorage} from 'ionic/ionic';
* @Page({
* template: `<ion-content></ion-content>`
* });
* export class MyClass{
* constructor(){
* this.local = new Storage(LocalStorage);
* this.local.set('didTutorial', true);
* }
*}
*```
* @demo /docs/v2/demos/local-storage/
* @see {@link /docs/v2/platform/storage/ Storage Platform Docs}
*/
@@ -17,6 +33,11 @@ export class LocalStorage extends StorageEngine {
constructor() {
super();
}
/**
* Get the value of a key in LocalStorage
* @param {String} key the key you want to lookup in LocalStorage
*/
get(key) {
return new Promise((resolve, reject) => {
try {
@@ -27,6 +48,12 @@ export class LocalStorage extends StorageEngine {
}
});
}
/**
* Set a key value pair and save it to LocalStorage
* @param {String} key the key you want to save to LocalStorage
* @param {Any} value the value of the key you're saving
*/
set(key, value) {
return new Promise((resolve, reject) => {
try {
@@ -37,6 +64,11 @@ export class LocalStorage extends StorageEngine {
}
});
}
/**
* Remove a key from LocalStorage
* @param {String} key the key you want to remove from LocalStorage
*/
remove(key) {
return new Promise((resolve, reject) => {
try {