LC Web integration is not good enough

Andre Garzia andre at andregarzia.com
Mon Apr 30 17:30:00 EDT 2018


Hi Friends,

This is a bit of a rant because I can't believe no one stopped by these
kind of problems before.

First of all, the JS Handlers for a browser widget are one way only. There
is no way to call a LiveCode function from JS and actually see a response.
You need to code two JS functions, one for calling LC and another for
receiving the LC response in an analog (even worse) to the old callback
hell of JS from early 2000. I find this quite unacceptable, it makes
impossible to make multiple calls to LC to retrieve values without
devolving into a spiral of callbacks.

Besides the only way to execute JS code from LC is to use the do statement,
which works with strings making it hard to assemble values compatible with
JS. You need to go like building SQL statements in 1990s by concatenating a
JS to be executed which is not only error prone, it is error certain. It
will fail if you are building something really complext because....

Because LC jsonExport routines are broken, for they will export an array as
an object, which makes no sense at all. For example, if you have an array
like:

t[1]["name"] = "andre"
t[2]["name"] = "cleo"

jsonExport will output:

{"1": {"name": "andre"},"2": {"name": "cleo"}}
instead of the correct:

[{"name": "andre"}, {"name": "cleo"}]

If you pick an array, pass through that jsonExport routine, assemble a
correct JS string, send it to the web widget and the JS on the other side
is expecting an array, it will fail because that is an object.

So, in summary:

* We have subpar integration that relies on callback hell
* The json routines don't work
* The integration to execute JS from LC relies on error-prone hand
assembled strings

The worst thing for me is the JSON library exporting objects. How did this
didn't affected people on this list on the past is a bit beyond me.

I am doing a simple round-trip execution of LC + JS here and it is taking
me hours because I need to fight the current buggy feature implementations
instead of focusing on my own business logic.

-- 
http://www.andregarzia.com -- All We Do Is Code.
http://fon.nu -- minimalist url shortening service.



More information about the use-livecode mailing list