-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Framework functions receive arguments boxed twice in an Array #214
Comments
Hi, I noticed the same as I was working on upgrading an app from cordova-electron 1.x to 3.x With 1.x I was able to access the main process using the options nodeIntegration = true and contextIsolation = false in browserWindow.webPreferences, but as this is not supported anymore in cordova-electron 3.x, I deep dived into the code to understand how it works and how can I create a plugin that runs in the main process. I'm going to fork cordova-electron to try to this, and also to call the framework function with parameters (succes, fail, args) to make it more similar to "browser" platform and address the fact that if you have to run the error function, Electron returns a string wrapped in an Error object. |
…cdv-plugin-exec The main goal was to allow passing to the error callback an unaltered copy of the argument, as with the previous implementation you have to throw an exception or return a rejected promise, and this is forwarded to the ipcRenderer.invoke as a string encapsulated in an Error object. See electron/electron#24427 Moreover, with the previous implementation, args for the action were encapsulated twice in an Array ( see apache#214 ). To make it more coherent with Cordova standards, and to allow backward support easily with a simple check, the first and the second arguments are success and error functions, and the third argument is the args array. So if the first argument is a function, we are using this cordova-electron~4 proposal, otherwise we are using cordova-electron~3, and it is the "arguments" array. Finally, _cdvElectronIPC.exec checks if success and error parameters are actually functions before calling them, in order to avoid annoying error log messages if they were not defined.
I'm not sure this is intentional or not, but I don't see the reason for the arguments to be boxed twice in an array when reaching the main process of a framework plugin/element. That is:
cordova.exec
transfers the array of argument to_cdvElectronIpc
, which in turns send the array to the main processcdv-plugin-exec
handler uses vararg for the last argument, which basically boxes the argument into another arrayIs this intentional?
The text was updated successfully, but these errors were encountered: