[Pas2js] JS Sync/Async Limitations

Sergei Vertiev vertiev at gmail.com
Thu Feb 21 16:04:08 CET 2019


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

Best regards
Sergei Vertie

On Thu, Feb 21, 2019 at 5:34 PM warleyalex via Pas2js
<pas2js at lists.freepascal.org> wrote:
>
> I don't know you, it would be really cool to have await keyword native in
> pas2js.
> the "async" keyword to allow us to program using asynchronous requests in a
> "synchronous" manner.
>
> in modern JS:
>
> async function r() {
>   var r2 = await fetch('https://jsonplaceholder.typicode.com/posts/1');
>   var j = await r2.json();
>   console.log(j);
> };
> r();
>
>
>
>
> --
> Sent from: http://pas2js.38893.n8.nabble.com/
> _______________________________________________
> Pas2js maillist  -  Pas2js at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js


More information about the Pas2js mailing list