Hello:

    How can we use that new interface? There's no documentation and our 
current lib doesn't expose said addJSCallback() yet (and updating c1 libs 
didn't help). Also, is the fix already available in the build servers? I 
should emphasize our code stopped working two or three days ago, so I'm not 
sure about the race condition been there for so long.

Kind regards,
    Kandy.


On Wednesday, January 3, 2018 at 2:47:04 PM UTC+1, Steve Hannah wrote:
>
> This looks like a race condition that has been there for a while.  I have 
> just committed a fix for it here
>
> https://github.com/codenameone/CodenameOne/commit/783ac2828409aa747103a35001b4886e24944484
>
> With the last update, however, the com.codename1.javascript package is now 
> deprecated in favour of a new async API that is incorporated directly into 
> the BrowserComponent class.  I recommend migrating over to this new API for 
> new code, as it will produce much better performance (no hidden 
> invokeAndBlock under the hood - except in xxxAndWait() methods).
>
> Using the new API, your code would become:
>
> bc.addJSCallback("window.checkfoxClickedCallback ={setChecked: function(){ 
> callback.onSuccess(null)}}", r->{
>     Log.p("->checkboxClickedCallback.setChecked()");
>     contexto.mostrarMensaje("checkboxClickedCallback.setChecked()");
> });
> bc.addJSCallback("window.okButtonClickedCallback = {showMap: function() { 
> callback.onSuccess(null)}}", r->{
>      Log.p("->okButtonClickedCallback.showMap()");
>      contexto.mostrarMensaje("okButtonClickedCallback.showMap()");
> });
>
> Notice, with this new syntax, you reference the java callback explicitly 
> in the javascript code via the "callback" variable, which, in Javascript, 
> contains 2 methods: onSuccess(arg), and onError(message, code).
>
> Steve
>
>
>
>
> On Wed, Jan 3, 2018 at 5:09 AM, <[email protected] <javascript:>> wrote:
>
>> Hello:
>>
>>     Since the last codename1 libary update we've been having problems 
>> with the BrowserComponent on iOS. We've narrowed down the problem to the 
>> callback registration process (which gets executed on the BrowserComponent 
>> onLoad callback). We register two functions, but only the second one can be 
>> invoked from javascript. The first one gets registered ok (we can see its 
>> code from the javascript side) but fails to execute on iOS (in Android and 
>> the simulator works fine). We tried a lot of permutations, and different 
>> argument lengths for both functions, but the only difference we see is the 
>> registration order. If we switch the registration order, we can only invoke 
>> the other one (whichever gets registered last).
>>
>> /*
>> * Registramos el callback JS de valor cambiado del checkbox "No volver a 
>> mostrar este asistente". 
>> */
>> JSObject checkboxClickedCallback = (JSObject) javascriptContext.get("{}");
>> checkboxClickedCallback.set("setChecked", new JSFunction() {
>> public void apply(JSObject self, Object[] args) {
>> Log.p("->checkboxClickedCallback.setChecked()");
>> contexto.mostrarMensaje("checkboxClickedCallback.setChecked()");
>>
>> }
>> });
>> javascriptContext.set("window.checkboxClickedCallback", 
>> checkboxClickedCallback);
>>
>> /*
>> * Registramos el callback JS de click en el botón "OK".
>> */
>> JSObject okButtonClickedCallback = (JSObject) javascriptContext.get("{}");
>> okButtonClickedCallback.set("showMap", new JSFunction() {
>> public void apply(JSObject self, Object[] args) {
>> Log.p("->okButtonClickedCallback.showMap()");
>> contexto.mostrarMensaje("okButtonClickedCallback.showMap()");
>>
>> }
>> });
>> javascriptContext.set("window.okButtonClickedCallback", 
>> okButtonClickedCallback);
>>
>>     Please help, as it's impacting our current production code.
>>
>> Kind regards,
>>      Kandy
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "CodenameOne Discussions" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] 
>> <javascript:>.
>> Visit this group at 
>> https://groups.google.com/group/codenameone-discussions.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/codenameone-discussions/493a9217-0a4a-44b5-aede-974096f652d4%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/codenameone-discussions/493a9217-0a4a-44b5-aede-974096f652d4%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Steve Hannah
> Software Developer
> Codename One
> http://www.codenameone.com
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/0aa6820b-d038-4a3f-82ad-c45fb4c6d5e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to