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