diff --git a/ionic/platform/storage/local-storage.ts b/ionic/platform/storage/local-storage.ts index 8d4309f521..7d7794d1e7 100644 --- a/ionic/platform/storage/local-storage.ts +++ b/ionic/platform/storage/local-storage.ts @@ -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: `` + * }); + * 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 {