Tuesday, February 5, 2013

How to "embrace" asynchrony in GWT apps?

I read it and heard it from GWT gurus that because of the nature of AJAX apps, we should embrace the asynchronous nature of the calls. I understand the concept but I am not 100% sure about how to design the following requirement:

My View displays some data that is produced using the combination of some data from an RPC call and some data from local (it's a mobile app, so it gets some data from local file or db). The Presenter is supposed to get all the required data and refresh the view.

Now, I want to wrap all these individual calls (one call to RPC and one call to fetch local data), into a single call in a Facade. So ideally, in my Presenter, i want to call :

facade.getAllData( new MyCallBackHander(){
     void onFailure(){ }
     void onSuccess(){
       update the model and call refresh on the view
     }
 }  );

I am not sure if this is the right approach. I would like to use this pattern for all the calls made by various Presenters and I am not sure how to make it generic and how to code the getAllData method in the facade.

Please help.
thank you!

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

No comments:

Post a Comment