[Pas2js] TDataset load local JSON in a async way. How?
Michael Van Canneyt
michael at freepascal.org
Sat Aug 29 10:04:42 CEST 2020
On Fri, 28 Aug 2020, warleyalex via Pas2js wrote:
> Following this piece of code:
>
> fConnection.Active := true; // fDataSet should be Active BUT is still
> FALSE
> console.log( fDataset.Active ); // we've got a FALSE status because we
> are loading JSON in async way
>
> The ugly workaround, I have to use the setTimeout with 50ms
>
> window.setTimeout(procedure()
> begin
> console.log( fDataset.Active ); // we've got TRUE status
> end, 50);
I don't see how setting a connection to active can activate datasets,
but we'll leave that aside for the sake of argument:
There is no need for timers. Every dataset has an AfterOpen event.
Why not use that to populate the fishrecord ?
That's how I do it in all my code. Call Load, and in the AfterOpen event
handler I do whatever is needed.
That's what these event handlers are for, after all.
Michael.
More information about the Pas2js
mailing list