[Pas2js] RES: Pas2js Digest, Vol 39, Issue 1
Wagner Landgraf
wagner at tmssoftware.com
Tue Jun 1 13:24:01 CEST 2021
>
>> Unit MyTest;
>>
>> procedure Run; async;
>> begin
>> // do something...
>> end;
>>
>> begin
>> run()._then(function (a : jsvalue) : jsvalue
>> begin
>> end);
>> end.
>>
>> In the line "run()._then(function (a : jsvalue) : jsvalue” give me the error “Error: illegal qualifier "." after " run():Procedure/Function"”
>
> I don't think you can use a procedure, you must use a function.
>
> Mattias will have to confirm.
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;
More information about the Pas2js
mailing list