Skip to content

Commit

Permalink
invokeMethod could be called with async
Browse files Browse the repository at this point in the history
  • Loading branch information
OllegK committed Mar 16, 2023
1 parent fcc44b5 commit 6a5217e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/nexus-bridge/src/NexusBaseApplet.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,20 @@ export default class NexusBaseApplet {
return this.pm.ExecuteMethod('CanInvokeMethod', method)
}

invokeMethod(method) {
invokeMethod(method, { async, cb } = {}) {
// TODO: check if the method in the local array? or maybe skip checking for canInvokeMethod
if (!this.canInvokeMethod(method)) {
return false
}
if (async) {
const promise = new Promise((resolve) => this.pm.ExecuteMethod('InvokeMethod', method, null, {
async,
cb: function() {
resolve.call(null, [].slice.call(arguments))
},
}))
return typeof cb === 'function' ? promise.then(cb) : promise
}
return this.pm.ExecuteMethod('InvokeMethod', method)
}

Expand Down

0 comments on commit 6a5217e

Please sign in to comment.