miroslavvojtus opened a new issue #1159:
URL: https://github.com/apache/cordova-ios/issues/1159


   # 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');
       }
     }
   }
   ```
   
   
   


-- 
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]

Reply via email to