TXDataWebConnection and onConnect running twice

Hi,

I noticed that when I refresh the page with the WEB Core App which connects to the XData via TXDataWebConnection the onConnect event is running twice.
I see in the network tab that gets the $model service twice. Is it normal behavior?

Yes, that's ir normal. A refresh is simply causing the application to fully reload and execute again from the starting point.

Ok ... but onConnect should be run only once... why is running twice? I have in that event some stuff that will be done after a connection is established and now this stuff is running twice it is a little bit annoying :slight_smile:

I don't know, it should be called only once. I would have to see your source code to tell what's going on.

Workaround (maybe not pretty) is to set the tag to 1 to avoid double doing the same code:

procedure TdmDataModule.conXDataConnect(Sender: TObject);
begin
  //console.log('onConnect');
  if ((Application.isOnline) and (conXData.Tag=0)) then
    begin
      DSDataStatus;
      conXData.Tag:=1;
    end;
end;

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