Define exec proxy with js-module
- Dominant language
- JavaScript
- Stars
- 2.2k
- Forks
- 1k
- Avg merge
- 12h 11m
- Merged PRs (30d)
- 18
Description
# Feature Request
## Motivation Behind Feature
I have some logic which is iOS specific but I do not want to write it in native source code.
I would like just to write simple js-module which should after registration of relevant proxy be able to the iOS specific job done.
Right now any `cordova/exec` on iOS bypasses the registered `cordova/exec/proxy` registered proxy in case there is no need to implement the code natively.
## Feature Description
I would like to define ios specific js-module like:
```
require('codrova/exec/proxy').add('MyService', {
init: (success, fail) => {
console.log('Do my job');
success();
}
})
```
In platfrom brige js-module code you could call:
```
require('cordova/exec')(() => console.loog('initialized'), console.error, 'MyService', 'init')
```
Currently I would get the following error from native iOS: "Plugin 'MyService' not found, or is not a CDVPlugin. Check your plugin mapping congfig.xml."
I would suggest one of:
- first check if a proxy is registered and if yes execute it in place and do not attempt to call native else call native and fail if not existent.
- first check if there is native plugin to execute else attempt to execute proxy
## Alternatives or Workarounds
I have to do the logic manually in my bridge code:
```
module.exports = {
init: (success, fail) => {
const proxyAction = require('cordova/exec/proxy').get('MyService', 'init');
if (typeof proxyAction === 'function') {
proxyAction(success, fail);
} else {
require('cordova/exec')(success, fail, 'MyService', 'init');
}
}
}
```
Contributor guide
Research direction
Start by tracing the cordova/exec and cordova/exec/proxy entry points in the iOS platform bridge, including proxy registration and lookup. Compare the proposed proxy-first and native-first behaviors, then define and document the dispatch precedence. Done means a registered JavaScript proxy can handle the example service action while native calls still work when no proxy is available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, javascript
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100