Using callbacks within LC and JS

jonathandlynch at gmail.com jonathandlynch at gmail.com
Wed May 31 09:29:09 EDT 2017


Yah - setting up threads that include JS event listeners was a big pain for Augmented Earth - I have no suggestions for simplifying that part.

That bit of complexity seems unavoidable to me.


Sent from my iPhone

> On May 31, 2017, at 9:15 AM, hh via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Sadly this is only valid if the js jobs you do are non-threaded and
> do not use workers, rather than being a matter of logic.
> 
> But the speed gain by using javascript in the browser is often only
> due to multi-threading.
> 
> We don't have always control about all parts of a js library. We can't
> "split" then into non-threaded jobs.
> Usually one has to work really hard with promises. The sums that BR
> mentioned for doing synchronous communication are pretty much
> appropriate. We should collect for the (most expensive) offer of the
> core-team relating the borwser widget.
> 
>> Jonathan Lynch wrote:
>> I just wanted to explain my view on why callbacks are not as horrible
>> as they seem at first, if one structures the script logically.
>> 
>> The below code explains:
>> 
>> On LCcontrolScript pcommand,pdata
>> 
>> If pcommand = empty then
>> Put "step1();" into tJS
>> Do tJS in widget "my browser"
>> 
>> Else if pcommand = "return from step 1" then
>> -- process pdata 
>> Put "step2();" into tJS
>> Do tJS in widget "my browser"
>> 
>> Else if pcommand = "return from step 2" then
>> --process pdata 
>> Put "step3();" into tJS
>> Do tJS in widget "my browser
>> 
>> Else if pcommand = "return from step 3" then
>> --process pdata 
>> --Finish doing whatever it needs and enjoy a great JavaScript display
>> End if
>> 
>> End LCcontrolScript
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list