mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-22 01:19:36 +08:00
parent
028a568515
commit
67adb23a14
@ -407,9 +407,9 @@ export function CordovaInstance(opts: any = {}) {
|
|||||||
* Before calling the original method, ensure Cordova and the plugin are installed.
|
* Before calling the original method, ensure Cordova and the plugin are installed.
|
||||||
*/
|
*/
|
||||||
export function CordovaProperty(target: any, key: string) {
|
export function CordovaProperty(target: any, key: string) {
|
||||||
|
const pluginInstance = getPlugin(target.pluginRef);
|
||||||
const exists = () => {
|
const exists = () => {
|
||||||
let pluginInstance = getPlugin(target.pluginRef);
|
if (!pluginInstance || pluginInstance[key] === 'undefined') {
|
||||||
if (!pluginInstance) {
|
|
||||||
pluginWarn(target, key);
|
pluginWarn(target, key);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -419,14 +419,14 @@ export function CordovaProperty(target: any, key: string) {
|
|||||||
Object.defineProperty(target, key, {
|
Object.defineProperty(target, key, {
|
||||||
get: () => {
|
get: () => {
|
||||||
if (exists()) {
|
if (exists()) {
|
||||||
return getPlugin(target.pluginRef)[key];
|
return pluginInstance[key];
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
set: (value) => {
|
set: (value) => {
|
||||||
if (exists()) {
|
if (exists()) {
|
||||||
getPlugin(target.pluginRef)[key] = value;
|
pluginInstance[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user