cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Jan de Wit <ede...@redhat.com>
Subject Re: Android Plugin API
Date Thu, 29 May 2014 08:25:01 GMT

On 28 May,2014, at 22:07 , Shazron <shazron@gmail.com> wrote:

> https://github.com/apache/cordova-ios/blob/50ca482c8e861c1aa480dadba726b1abbacbc0e1/CordovaLib/Classes/CDVCommandQueue.m#L193-L198

Right thanks, that is how I expected it to work, so why not use the same logic in Android
as on iOS? In Java one can also find a method based on the action name and invoke it. I would
say it’s less error prone then doing string comparison yourself. 

> 
> 
> On Wed, May 28, 2014 at 12:05 PM, Erik Jan de Wit <edewit@redhat.com> wrote:
> 
>> 
>>> 
>>> I don't know, it very much could be.  It could be that this makes sense
>> in
>>> Obj-C but not in Java based on how they handle NoSuchMethod.  I'd prefer
>> to
>>> not have to rely on an exception being caught, especially since it could
>>> suppress other exceptions being thrown that I want to know about.
>> 
>> Sending a message (calling a method) in object-c for a method that doesn’t
>> exist will also throw an exception, I haven’t looked at the implementation
>> but I would suspect that there is a test to see if the method (selector) is
>> there.
>> 
>>> 
>>> Also, I'm assuming the exception is NoSuchMethod, which isn't a safe
>>> assumption given that each device has their own quirks and this isn't
>>> guaranteed.
>> 
>> One could just lookup if the method exist and not just try to invoke it
>> and wait for the NoSuchMethod. That way one could make the error handling
>> nicer, for example:
>> 
>> You have a method called ‘myAction’ but it does not have the proper method
>> signature! Found public void myAction() but should be pubic PluginResult
>> myAction(JSONArray, CallbackContext)
>> 
>> 


Mime
View raw message