Passing an async procedure as argument (Part 2)

Unfortunately this thread is already closed

I’m running into the same issue. This is really inconvenient, since I’ve been using this kind of handover extensively in all my projects. Now I have to rework every single project, which is going to take a lot of effort. And I can’t yet tell if there will be side effects.

Is there a way to solve this more easily?

Error:
[Fehler] Pfand.Pfandware.Edit.pas(254): Incompatible type for arg no. 1: Got "TJSPromise", expected "TExecOnReadyCall"

Here is my example usage:

TMyForm = class ...
    [async] procedure ShowData;

procedure TMyForm.xxxxxxxx;
begin
  ...
  if FormField[ cLoaded] then
    ExecOnReady( ShowData)    // <-- Now Error
  else if FPageState = esEdit then
    ExecOnReady( LoadData)
  else
    InitData;
  ...
end;

in another unit, available globally

procedure TWebDataForm.ExecOnReady( AExecProc: TExecOnReadyCall);
begin
  if CheckIsReady then
    AExecProc
  else
    FOnReadyExecList.Add( TExecOnReadyEvent.Create( AExecProc));
end;

This isn't an isolated case. I have several such uses.

Is there a way to make my work easier?

Afaik, all you need to do is add the @ prefix on methods you pass as TProc parameter.
This is something that was made more strict in a recent pas2js transpiler update.

Sometimes it can be so simple :wink:

Thank you

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.