From 1e1920f524a4ed697498bb51fd50757921da7e41 Mon Sep 17 00:00:00 2001 From: mru Date: Thu, 16 Feb 2017 18:38:09 +0100 Subject: [PATCH] replaced callback functions with promises --- src/plugins/apppreferences.ts | 50 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/plugins/apppreferences.ts b/src/plugins/apppreferences.ts index 401f11790..268497d27 100644 --- a/src/plugins/apppreferences.ts +++ b/src/plugins/apppreferences.ts @@ -32,74 +32,72 @@ export class AppPreferences { /** * Get a preference value * - * @param {Function} successCallback The function to call when the value is available - * @param {Function} errorCallback The function to call when value is unavailable - * @param {string} dict Dictionary for key + * @param {string} dict Dictionary for key (OPTIONAL) * @param {string} key Key * @return {Promise} Returns a promise */ - @Cordova() - static fetch(successCallback: Function, errorCallback: Function, dict: string, key?: string): Promise { return; } + @Cordova({ + callbackOrder: 'reverse' + }) + static fetch(dict: string, key?: string): Promise { return; } /** * Set a preference value * - * @param {Function} successCallback The function to call when the value is set successfully - * @param {Function} errorCallback The function to call when value is not set - * @param {string} dict Dictionary for key + * @param {string} dict Dictionary for key (OPTIONAL) * @param {string} key Key * @param {string} value Value * @return {Promise} Returns a promise */ - @Cordova() - static store(successCallback: Function, errorCallback: Function, dict: string, key: string, value?: string): Promise { + @Cordova({ + callbackOrder: 'reverse' + }) + static store(dict: string, key: string, value?: string): Promise { return; } /** * Remove value from preferences * - * @param {Function} successCallback The function to call when the value is available - * @param {Function} errorCallback The function to call when value is unavailable - * @param {string} dict Dictionary for key + * @param {string} dict Dictionary for key (OPTIONAL) * @param {string} key Key * @return {Promise} Returns a promise */ - @Cordova() - static remove(successCallback: Function, errorCallback: Function, dict: string, key?: string): Promise { return; } + @Cordova({ + callbackOrder: 'reverse' + }) + static remove(dict: string, key?: string): Promise { return; } /** * Clear preferences * - * @param {Function} successCallback The function to call when the value is available - * @param {Function} errorCallback The function to call when value is unavailable * @return {Promise} Returns a promise */ - @Cordova() - static clearAll(successCallback: Function, errorCallback: Function): Promise { return; } + @Cordova({ + callbackOrder: 'reverse' + }) + static clearAll(): Promise { return; } /** * Show native preferences interface * - * @param {Function} successCallback The function to call when the value is available - * @param {Function} errorCallback The function to call when value is unavailable * @return {Promise} Returns a promise */ - @Cordova() - static show(successCallback: Function, errorCallback: Function): Promise { return; } + @Cordova({ + callbackOrder: 'reverse' + }) + static show(): Promise { return; } /** * Show native preferences interface * - * @param {Function} successCallback The function to call when the value is available - * @param {Function} errorCallback The function to call when value is unavailable * @param {boolean} subscribe true value to subscribe, false - unsubscribe * @return {Observable} Returns an observable */ @Cordova({ observable: true }) - static watch(successCallback: Function, errorCallback: Function, subscribe: boolean): Observable { return; } + static watch(subscribe: boolean): Observable { return; } /** * Return named configuration context