Device ready call

This commit is contained in:
Max Lynch
2015-11-29 16:30:15 -06:00
parent 3327fe8f45
commit 45dc983752
23 changed files with 150 additions and 14 deletions
+7 -1
View File
@@ -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;
}