[Pas2js] JS Sync/Async Limitations

Michael Van Canneyt michael at freepascal.org
Thu Feb 21 16:08:18 CET 2019



On Thu, 21 Feb 2019, Sergei Vertiev wrote:

> Hello, warleyalex!
> I sure know about async functions and try this as "asm" stuff in my code.
> Do you know, that when you call "async" function this returns immidiatelly?
> so:
>
> ---------------------------------------------
> async function r() {
>  var r2 = await fetch('https://jsonplaceholder.typicode.com/posts/1');
>  var j = await r2.json();
>  console.log("RESULT:"+j);
> };
> r();
> console.log("FINISH");
> ---------------------------------------------
> Console output will be:
>
> FINSIH
> RESULT:xxxxxxxx

Exactly my point. It does not solve your problem of lazy loading.

Michael.


More information about the Pas2js mailing list