cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Don Coleman <don.cole...@gmail.com>
Subject Re: [All Platforms][CordovaJS] NO_RESULT handling
Date Thu, 08 Jan 2015 21:10:58 GMT
@Shazron the problem has been around for a while, I've just been avoiding
it by running Cordova 4.0.0 / iOS 3.6.0

Changing Line 293
<https://github.com/apache/cordova-ios/compare/3.6.x...3.7.x#diff-f151c4cb27b3afeea45c8a625186e011L293>
to else is what broke things.

@Jessie applying the changes directly to cordova,js fixes things.

@Andrew thanks for the clarification on the NO_RESULT. I think I can remove
it from most places in my plugins. (There are a few places that rely on a
NO_RESULT return to silently remove a long running callback after it's no
longer needed.)


On Thu, Jan 8, 2015 at 3:30 PM, Shazron <shazron@gmail.com> wrote:

> Don, this change was just proposed and hasn't been implemented yet, so
> I'm not sure how you see a difference.
>
> https://github.com/apache/cordova-ios/compare/3.6.x...3.7.x
>
> On Thu, Jan 8, 2015 at 11:02 AM, Don Coleman <don.coleman@gmail.com>
> wrote:
> > I know this is an old thread but I'm seeing problems with this in my
> > Bluetooth plugins now that people are upgrading.
> >
> > Cordova 4.1.2 with iOS 3.7.0 is broken. NO_RESULT calls the failure
> > callback.
> > After downgrading to Cordova 4.0.0 with iOS 3.6.0 the plugin works as
> > expected.
> >
> > I use NO_RESULT since I hold onto command.callbackId when a Cordova
> method
> > is called and call the callback later from an iOS delegate callback.
> >
> >
> https://github.com/don/BluetoothSerial/blob/master/src/ios/MEGBluetoothSerial.m#L148
> >
> >
> > I was under the impression that i needed to call [pluginResult
> > setKeepCallbackAsBool:TRUE]; to keep the callback. Is this false?
> >
> > Can I just remove all the iOS calls that return NO_RESULT?
> >
> >
> >
> >
> > On Tue, Nov 25, 2014 at 2:15 PM, Andrew Grieve <agrieve@chromium.org>
> wrote:
> >
> >> My guess as to why NO_RESULT exists, is because on Android, plugin
> >> functions used to *have* to return a PluginResult. The only way to not
> have
> >> this reach JS was to set it to NO_RESULT.
> >>
> >> I don't actually see a use-case to ever send a NO_RESULT now...
> >>
> >> But, I think your pseudocode seems correct in the issue.
> >>
> >> On Mon, Nov 24, 2014 at 5:59 PM, Shazron <shazron@gmail.com> wrote:
> >>
> >> > https://issues.apache.org/jira/browse/CB-8063
> >> >
> >> > What I am discussing requires a change in cordova.js that will affect
> >> > all platforms.
> >> >
> >> >
> >> > NO_RESULT (integer:0) is treated as success by iOS [1] and Android
> [2].
> >> >
> >> > On Android, NO_RESULT is not processed on the JS layer if keepCallback
> >> > is true [3]
> >> > while on iOS it is always sent.
> >> >
> >> > In cordova.js, lines 203-207 [4] seem to imply that you would only
> >> > call the success callback if the status was OK. However, the logic in
> >> > it, would send a failure callback for NO_RESULT (which is a
> >> > "success").
> >> >
> >> > I believe the intent was this pseudo-code:
> >> >
> >> > ```
> >> > if (success) {
> >> >     if (status is OK) {
> >> >         // call success callback
> >> >     } else {
> >> >         // do nothing, NO_RESULT (success)
> >> >     }
> >> > } else {
> >> >     // call fail callback
> >> > }
> >> >
> >> > ```
> >> >
> >> > QUESTION:
> >> > However, I think if it was NO_RESULT, shouldn't it call the success
> >> > callback anyway since it was a success? Or is NO_RESULT expected to
> >> > not call any callback? I don't know the answer to this, nor could I
> >> > find any docs to suggest that is the way it is. I think we need to be
> >> > consistent on the behaviour of the NO_RESULT status code, with minimal
> >> > impact to existing plugin code.
> >> >
> >> >
> >> > ---------
> >> >
> >> > [1]
> >> >
> >>
> https://github.com/apache/cordova-js/blob/f6db82f4c737bd96a14fbc77e0a67b6d799ec06a/src/ios/exec.js#L308
> >> > [2]
> >> >
> >>
> https://github.com/apache/cordova-android/blob/fbeb379f1b2102d9d0739f92340c932bdc47873b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java#L509
> >> > [3]
> >> >
> >>
> https://github.com/apache/cordova-android/blob/fbeb379f1b2102d9d0739f92340c932bdc47873b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java#L238-L243
> >> > [4]
> >> >
> >>
> https://github.com/apache/cordova-js/blob/1fc2526faa6197e1637ecb48ebe0f876f008ba0f/src/cordova.js#L203-L207
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
> >> > For additional commands, e-mail: dev-help@cordova.apache.org
> >> >
> >> >
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
> For additional commands, e-mail: dev-help@cordova.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message