HTML5 deployment: progress comes into sight
Mark Wieder
ahsoftware at sonic.net
Sat Jun 3 21:19:35 EDT 2017
On 05/31/2017 02:35 PM, hh via use-livecode wrote:
> "Synchronous" means here that the callback is done in the order it appears in
> the list of js instructions, i.e. "synchronous to the instruction order".
>
> If you say in your js function
>
> instruction1;
> callback1;
> instruction2;
> callback2;
>
> then you can't control what's done first. This is the price we have
> to pay for speed (multi-threading).
> It is even possible that callback2 arrives at LC _before_ one of
> instruction1; callback1; instruction2;
> is finished.
I had a similar need in PowerDebug in order to handle asynchronous
events over socket connections for remote debugging. And dealt with it
thusly:
Requests are sent asynchronously and trigger a callback message when
they're done. The callback message payload contains a reference to the
message that called it. That way a callback handler can associate the
returned message with the calling handler, and if needed a wait loop can
implement a procedural pseudo-synchronous call.
It's kind of the way session cookies work in a browser. It probably
won't work for every use case, but when I need to define a statement
order from asynchronous events it does the trick.
--
Mark Wieder
ahsoftware at gmail.com
More information about the use-livecode
mailing list