Jump to content

Async version of JSCall


SantoshGnostice

Recommended Posts

I am looking for server side method which can invoke a JavaScript function that takes a callback and later asynchronously calls this callback which should result in a server-side call. Basically an async version of existing JSCall method which can take an anonymous function or a delphi callback. Is there such a method already present?

Link to comment
Share on other sites

A simple example of what I am looking for:

 

Server-side:

procedure CallBack(AResult: string);
begin
  // Control comes here after timeout
end;

JSAsyncCall('method', CallBack);

Client-side (JS):

method: function(callback) {
  setTimeout(callback, 1000, 'result');
}

I could use ajax to achieve this but I'd have to maintain a mapping on the server of all the callback functions and call them appropriately when the message arrives from the client. I am sure UniGUI must have solved this problem already - so I was looking to see if the framework has something I can use to achieve this.

Link to comment
Share on other sites

I have found an example implementation in UniGUI that may suit what I am looking for. The method "uniGUIDialogs.Prompt" takes a callback function which is called from the client-side once the user dismisses the dialog. Is there something similar which we can use when developing a custom component? How is the the Delphi callback procedure linked to the client-side callback?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...