Hi,
This has been on my mind as well, and I am wondering what a good solution to this would be.
This is semi-major in my opinion for working with cross-platform development between HTML5 and device builds. I’ve spent the last couple days rebuilding a fairly large device plugin from the ground up for HTML5 (JS), which is to be expected (and was certainly made much easier using Corona HTML5 Node Kit), but the major issue is that the developer will also need to either be very creative in how they build a cross-platform app or be required to build a device app, and then an additional HTML5 app.
In essence the developer interface to a plugin should be the same whether it is JS or Lua. I don’t imagine this to be an easy task, and I am extremely impressed with the parity so far. 
There are two things that stick out to me when trying to create a unified plugin interface for the developer.
- Properties (which I’ve mentioned in another post)
- Callbacks / Listeners
Working with properties could be handled with getters and setters, as long as that was worked into both the device plugin code and the JS plugin code. A little extra work, not my favorite solution, but doable.
The major one that I am running into is the callback interface. Here we lose all parity.
For device plugins we can do:
_ Device plugin _
... function doSomething(params, handler) return handler('whatever') end ...
Lua
local function handler(e) --callback stuff end myplugin.doSomething(params, handler)
But for JS, the workflow is something like:
JS plugin
... function doSomething(params, event\_id) { this.dispatchEvent({name: event\_id, data: 'whatever'}) } ...
Lua
local function handler(e) --callback stuff end myplugin.addEventListener('event\_id', handler) mypluing.doSomething(params, 'event\_id')
The only workaround that I have considered so far is to have both the device and JS plugin be entirely event driven by using the system.newEventDispatcher in the device side plugin, but I don’t think this is commonly what most developers use/do. We also end up with:
obj.addEventListener(...) --JS --and obj:addEventListener(...) --System Dispatcher
Note the dot vs. colon syntax (EDIT: I realized the colon syntax issue can be worked around by wrapping my own addEventListener method into a module).
In short (or long at this point), being able to pass a handler function to the JS side would solve what I see is a major issue for cross-platform plugins. I don’t know what kind of magic it would take, but in my opinion the use of a plugin, whether device or HTML5, should be as transparent to the developer as possible.
-dev