[Pas2js] RES: Pas2js Digest, Vol 39, Issue 1

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Jun 1 13:50:43 CEST 2021


On Tue, 1 Jun 2021 08:24:01 -0300
Wagner Landgraf <wagner at tmssoftware.com> wrote:

>[...]
> Indeed, I had to create a function that return JSValue even for
> procedures that are not supposed to return anything:
> 
> function TXDataWebConnection.OpenAsync: JSValue; async;
> begin
>   Result := TJSPromise.new(
>     procedure(resolve, reject: TJSPromiseResolver)
>     begin
>       DoConnect(
>         procedure
>         begin
>           if Assigned(FOnConnect) then
>             FOnConnect(Self);
>           resolve(nil);
>         end,
>         procedure(Error: TXDataWebConnectionError)
>         begin
>           reject(EXDataWebConnectionException.Create(Error));
>         end
>       );
>     end
>   );
> end;

Why does this need an async?
Why not

function TXDataWebConnection.OpenAsync: TJSPromise;
begin
  Result := TJSPromise.new..

?


Mattias


More information about the Pas2js mailing list