mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-07 06:27:51 +02:00
* Sleep function
This commit is contained in:
parent
fe582f7957
commit
cac354d470
@ -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
30
packages/rtl/webutils.pas
Normal 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.
|
||||
|
Loading…
Reference in New Issue
Block a user