teh-mICON opened a new pull request, #247: URL: https://github.com/apache/cordova-electron/pull/247
<!-- Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines: http://cordova.apache.org/contribute/contribute_guidelines.html Thanks! --> ### Platforms affected electron browser (?) ### Motivation and Context <!-- Why is this change required? What problem does it solve? --> <!-- If it fixes an open issue, please link to the issue here. --> It is currently not possible to send more than one plugin response per service action call. This is not ideal in situations where a native process might generate more than one result over time. Additionally, the API is more in line with that of cordova-android and from what I can gather also cordova-ios ### Description <!-- Describe your changes in detail --> The version in this branch creates a callbackId in exec.js and passes it on to preload. preload registers this callbackId with ipcRenderer and invokes the callback. main creates a CallbackContext with this callbackId and passes it on to the service action dispatch service actions now have a similar API as android: (action: string, args: any, callbackContext: Object) [callbackContext]https://github.com/teh-mICON/cordova-electron/blob/4.0.x/bin/templates/platform_www/CallbackContext.js#L21) provides functions `success` and `error`. Additionally, it exposes the `PluginResult` class along with `sendPluginResult`. This makes it possible to send multiple results when keepCallback is set to true. There might be a better way to provide this API to plugins. ### Testing <!-- Please describe in detail how you tested your changes. --> I used document.addEventListener in the [plugin sample](https://github.com/teh-mICON/cordova-electron/blob/4.0.x/tests/spec/fixtures/test-app-with-electron-plugin/plugins/cordova-plugin-sample/www/init.js) to call [a demo implementation of the new api]((https://github.com/teh-mICON/cordova-electron/blob/4.0.x/tests/spec/fixtures/test-app-with-electron-plugin/plugins/cordova-plugin-sample/src/electron/index.js) ### Checklist - [ ] I've run the tests to see all new and existing tests pass - [ ] I added automated test coverage as appropriate for this change - [x] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`) - [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/)) - [x] I've updated the documentation if necessary Unfortunately I can't check any of these. I wasn't sure how the tests were supposed to be run but I created a sample app that tests for the functionality. ### Additional notes - The API changes would break existing plugins but it would be a new major version so depending on the maintainer's opinions that might be ok? If not, there is always the option to load the plugin package.json and check for an API flag. - I couldn't get the browser fallback to work so couldn't test for that. - Strictly speaking it applies to both electron and browser so the check is alright in that box I guess - I didn't find any documentation that applies -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
