Ravi Chandran
Ravi Chandran

Reputation: 131

In GWT the RPC call is Synchronous or Asynchronous

I'm getting confused a bit when it comes to Synchronous calls, and Asynchronous calls in GWT.

I am sure that GWT is makes Async calls.

It's clear to me that Synchronous is just waiting for the response, and after getting that response, executing the next command.

It is not in the case of Asynchronous, because it never waits for the response. Before getting the response it executes the next command right away.

But I can see in some blogs is says that RPC is Synchronous..... Whereas GWT which uses RPC is not Synchronous. I understand that whenever I send the request it never waits.

  1. Is RPC really synchronous?
  2. If so how does GWT make Async RPCs?

or did I misunderstand anything?

Upvotes: 1

Views: 1425

Answers (1)

chenmingi
chenmingi

Reputation: 66

GWT RPC(Remote Procedure Calls) is Asnyc for sure. Actually, All of implementations which are based on AJAX are all Asnyc. Let's take a look on the example below:

emailService.emptyMyInbox(fUsername, fPassword, new AsyncCallback() {
    public void onSuccess(Void result) {
      // do some UI stuff to show success
    }

    public void onFailure(Throwable caught) {
      // do some UI stuff to show failure
    }
};
// do something more

We call the service on first line, right after the execution, the browser will execute the line // do something more, regardless of if the result returned or not.

For more information, see Dev Guide Server Communication

Upvotes: 4

Related Questions