Saturday, June 18, 2011

Re: Is it ever possible for an asynchronous service method's callback to get called without yielding to the browser's event loop?

The only time I encounter what you describe is when I mock the server
side code on the client side. In other words, in your code example, I
might have myRemoteService actually be an instance of some
MyRemoteServiceAsyncMock, that returns dummy data while I wait for
someone else to write the server side impl (or until I do it myself).
In that case the async call is actually sync and so I might need a
deferred command to make sure that code outside the async call is run
before the call itself. Otherwise you should be able to count on
things happening in the expected order.

On Jun 17, 12:29 pm, Tad <tadwo...@gmail.com> wrote:
> Is the AsyncCallback framework implemented in such a way that when a
> RemoteService method is called, is it a GUARANTEE that the browser's
> event loop will execute at least one cycle before its callback (i.e.
> onSuccess or onFailure) gets called?
>
> For example:
>
> ...some code...
> myRemoteService.myMethod( myParameter, new AsyncCallback<String>()
> {
>    public void onSuccess(String result)
>    {
>       ....
>    }});
>
> ...some "long running" code...
>
> In the above example, if the result of myMethod happens to return
> before the "some long running code" finishes, will the browser's event
> loop always receive at least one cycle before onSuccess() is called?
> Or is it ever possible that onSuccess() could get called without
> yielding to the browser's event loop?
>
> Another way to ask this question would be: Is there ever a scenario
> where it is necessary to do the following (or put the scheduleDeferred
> call inside myMethod's onSuccess callback)?
>
> Schedule.get().scheduleDeferred( new ScheduledCommand()
> {
>    myRemoteService.myMethod( myParameter, new AsyncCallback<String>()
>    {
>       public void onSuccess(String result)
>       {
>          ....
>       }
>    });
>
> });
>
> -Tad

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate