mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-04-13 00:00:10 +08:00
Device ready call
This commit is contained in:
@@ -5,9 +5,15 @@ declare var Promise;
|
||||
|
||||
export const wrap = function(pluginObj, methodName, opts: any = {}) {
|
||||
return (...args) => {
|
||||
console.log('Trying', pluginObj.name, methodName, args);
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
if(!window.cordova) {
|
||||
console.warn('Native: tried calling ' + pluginObj.name + '.' + methodName + ', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
|
||||
reject({
|
||||
error: 'cordova_not_available'
|
||||
})
|
||||
}
|
||||
|
||||
if(typeof opts.successIndex !== 'undefined') {
|
||||
args[opts.successIndex] = resolve;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user