mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-03-17 00:51:07 +08:00
feat(plugin): add sync option to @Cordova for sync functions
This commit is contained in:
parent
5bed810624
commit
17e3827831
5
dist/plugins/plugin.js
vendored
5
dist/plugins/plugin.js
vendored
@ -114,7 +114,10 @@ exports.wrap = function (pluginObj, methodName, opts) {
|
|||||||
for (var _i = 0; _i < arguments.length; _i++) {
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||||||
args[_i - 0] = arguments[_i];
|
args[_i - 0] = arguments[_i];
|
||||||
}
|
}
|
||||||
if (opts.observable) {
|
if (opts.sync) {
|
||||||
|
return callCordovaPlugin(pluginObj, methodName, args, opts);
|
||||||
|
}
|
||||||
|
else if (opts.observable) {
|
||||||
return wrapObservable(pluginObj, methodName, args, opts);
|
return wrapObservable(pluginObj, methodName, args, opts);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
2
dist/plugins/plugin.js.map
vendored
2
dist/plugins/plugin.js.map
vendored
File diff suppressed because one or more lines are too long
@ -32,7 +32,7 @@ export const cordovaWarn = function(pluginName: string, method: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function callCordovaPlugin(pluginObj:any, methodName:string, args:any[], opts:any={}, resolve:any, reject:any) {
|
function callCordovaPlugin(pluginObj:any, methodName:string, args:any[], opts:any={}, resolve?: Function, reject?: Function) {
|
||||||
// Try to figure out where the success/error callbacks need to be bound
|
// Try to figure out where the success/error callbacks need to be bound
|
||||||
// to our promise resolve/reject handlers.
|
// to our promise resolve/reject handlers.
|
||||||
|
|
||||||
@ -121,7 +121,9 @@ function wrapObservable(pluginObj:any, methodName:string, args:any[], opts:any =
|
|||||||
export const wrap = function(pluginObj:any, methodName:string, opts:any = {}) {
|
export const wrap = function(pluginObj:any, methodName:string, opts:any = {}) {
|
||||||
return (...args) => {
|
return (...args) => {
|
||||||
|
|
||||||
if(opts.observable) {
|
if (opts.sync){
|
||||||
|
return callCordovaPlugin(pluginObj, methodName, args, opts);
|
||||||
|
} else if (opts.observable) {
|
||||||
return wrapObservable(pluginObj, methodName, args, opts);
|
return wrapObservable(pluginObj, methodName, args, opts);
|
||||||
} else {
|
} else {
|
||||||
return wrapPromise(pluginObj, methodName, args, opts);
|
return wrapPromise(pluginObj, methodName, args, opts);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user