[Pas2js] Async, AWait
Michael Van Canneyt
michael at freepascal.org
Thu May 28 14:30:58 CEST 2020
On Thu, 28 May 2020, silvioprog wrote:
> On Thu, May 28, 2020 at 5:12 AM Michael Van Canneyt <michael at freepascal.org>
> wrote:
>
>> On Thu, 28 May 2020, Mattias Gaertner via Pas2js wrote:
>>> Hi all,
>>>
>>> pas2js trunk now supports async procedures and await functions.
>>> This can greatly simplify writing asynchronous code, like starting a
>>> download, handle the result, depending on the result download the next
>>> piece and so forth.
>>> Formerly you needed some (anonymous) functions for that. Now you can
>>> write asynchronous code, that looks like normal, synchronous
>>> code.
>>>
>>> https://wiki.freepascal.org/pas2js_AsyncAWait
>>
>>
>> I have added the demos from the wiki page to the demo dir in the sources,
>> fixed a small error in one of the demos.
>>
>> Enjoy !
>>
>> Michael.
>
>
> I have a question.
>
> Is it possible to use parameters-less at the await part? For example:
>
> function foo: TJSBlob; *async*;
> var
> r: TJSResponse;
> begin
> r := *await* window.fetch(url);
> ...
> Result := *await* r.blob();
> end;
>
> Thank you!
The fetch/blob example exists and works as-is.
Michael.
More information about the Pas2js
mailing list