cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Grieve <agri...@chromium.org>
Subject Re: [All Platforms][CordovaJS] NO_RESULT handling
Date Tue, 25 Nov 2014 19:15:48 GMT
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
>
>

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