[Pas2js] TDataset load local JSON in a async way. How?
warleyalex
warleyalex at yahoo.com.br
Fri Aug 28 03:30:11 CEST 2020
In this example:
https://pas2js.github.io/master/ProjectFishfacts/index.html
I use TDataset which inherits from TBaseJSONDataSet to load a local JSON
file.
If you see at
https://github.com/pas2js/pas2js.github.io/blob/master/master/ProjectFishfacts/ucds.pas
It is possible to load synchronously but there is that warning:
[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated
because of its detrimental effects to the end user's experience. For more
help, check https://xhr.spec.whatwg.org/.
--> FReq.open('GET',FURI, FALSE); // async = false
but would prefer TDataset to load asynchronously using the modern (async/
await / fetch). But unfortunately, I could not find a way.
function fetchAsync(url: String): TJSPromise; {$ifndef
InLazIDE}async;{$endif}
var
response: TJSResponse;
data: TJSPromise;
begin
response := await(window.fetch( url ));
Result := await(response.json());
end;
Any idea how to TDataset load in a async way?
--
Sent from: http://pas2js.38893.n8.nabble.com/
More information about the Pas2js
mailing list