* Sleep function

This commit is contained in:
michael 2020-06-01 08:11:00 +00:00
parent fe582f7957
commit cac354d470
2 changed files with 31 additions and 1 deletions

View File

@ -341,6 +341,7 @@ function GetEnvironmentString(Index: Integer): String;
procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer = Nil);
Procedure Abort;
{*****************************************************************************
Events
*****************************************************************************}
@ -7894,6 +7895,5 @@ begin
Result:=BoolToStr(Self,UseBoolStrs=TUseBoolStrs.True);
end;
end.

30
packages/rtl/webutils.pas Normal file
View File

@ -0,0 +1,30 @@
unit webutils;
{$mode objfpc}
interface
uses
web, js;
function Sleep(ms: NativeInt): TJSPromise;
implementation
function Sleep(ms: NativeInt): TJSPromise;
begin
Result := TJSPromise.New(
procedure(resolve,reject : TJSPromiseResolver)
begin
window.setTimeout(
procedure()
begin
resolve(ms);
end,
ms);
end);
end;
end.