[Pas2js] Async procedure.

Michael Van Canneyt michael at freepascal.org
Mon May 31 21:06:32 CEST 2021



On Mon, 31 May 2021, Henrique Gottardi Werlang wrote:

> I'm making a remote request client and I had a problem.
>
> I declared an asynchronous procedure, but it doesn't generate a promise.
>
> This I can't register the "then” event.

Works fine here:

uses JS;

function Run: word; async;
begin
   Result:=3;
end;

begin
   run()._then(function (a : jsvalue) : jsvalue
     begin
     end);
end.

or

uses JS;

function Run: word; async;
begin
   Result:=3;
end;

var
   p: TJSPromise;
begin
   p:=Run(); // calling directly without await() returns a TJSPromise!
   p._then(function (a : jsvalue) : jsvalue
     begin
     end);
end.

So what does not work for you ?

Michael.


More information about the Pas2js mailing list