EXEC_JS - Get return value of async code / Available modes

SOLVED

Hello,

Does anyone know where I can find a documentation explaining the differences and how to use the modes "wait", "sync" and "future"? I have found some examples of EXEC_JS in the online help but those do not exactly explain the different modes and only have simple examples of synchronous functions calls.

I know how to publish JS functions in Syracuse and I sucessfully communicate with external services that end up returning a value. Unfortunately I do not get the return inside EM's 4GL because JS is asynchronous in nature.

My current solution is passing a "result file path" (generally filpath("tmp")+"\"+timestamp$) so that the JS function knows where to write the output to and having a "generic" function that waits for the file to exist (with a sleep+timeout mechanism) but I find this solution slow and very inefficient in cases where I need to have multiple calls.

What I expect to be possible: having a callback function that EM waits for, since EXEC_JS has that parameter (in "wait" mode). Unfortunately I have no idea how to use this callback function exactly (I think the _ variable which already points to a function is related though). Also, I have noticed that "future" mode returns an ID which I assume is a Promise reference or something like that, but I do not know how to check the status after.

Regards,
Roberto Nascimento