mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-31 18:49:43 +08:00
refactor(): optimize code
This commit is contained in:
parent
71f7051997
commit
dfd0514a43
@ -1,7 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CordovaInstance, Plugin, checkAvailability, IonicNativePlugin } from '@ionic-native/core';
|
||||
|
||||
declare var cordova: any;
|
||||
import { CordovaInstance, Plugin, CordovaCheck, IonicNativePlugin } from '@ionic-native/core';
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
@ -120,13 +118,10 @@ export class SecureStorage extends IonicNativePlugin {
|
||||
* @param store {string}
|
||||
* @returns {Promise<SecureStorageObject>}
|
||||
*/
|
||||
@CordovaCheck()
|
||||
create(store: string): Promise<SecureStorageObject> {
|
||||
return new Promise((res, rej) => {
|
||||
if (checkAvailability('cordova.plugins.SecureStorage', null, 'SecureStorage') === true) {
|
||||
const instance = new cordova.plugins.SecureStorage(() => res(new SecureStorageObject(instance)), rej, store);
|
||||
} else {
|
||||
res(new SecureStorageObject());
|
||||
}
|
||||
return new Promise((res: Function, rej: Function) => {
|
||||
const instance = new (SecureStorage.getPlugin())(() => res(new SecureStorageObject(instance)), rej, store);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user