Tuesday, April 24, 2012

best/good practices to keep Model in sync with Activity/Place and a view.

Since approximately one year i am coding with gwt and MVP pattern (also using "Activity" and "Places") . The VP-Part was never a big Problem. But i often stumbled over getting a "model" for current place or generally how to get from Place  to Model->Activity->View.
My main problem is that on start of an activity the model is mapped into a String (token of a place) and must be "resolved" to data objects (i.e. userId to userObject) . i think that is the main difference between "classic" MVP using an EventBus or other means to communicate state changes (via "real" objects) and A&P-based MVP that knows only two states: the current place.getWhere() and the next goTo(new Place) - each mapped to/from String mapped.
So whats the point: So far i tried many approaches to "resolve" the state, but all feels wrong:
The simplest is to  let the activity resolve the state by calling the needed async-services (to get an user for an userId). But as soon as two activity share the same place/model this code must be copied - bad. The other stuff i tried was even worse - my last attempt (also asked here) didn't work.

My question is: What is best/good practice to implement such a state resolver classes? Are there any examples (Place->Model->Place)?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/mEWYIcPRsosJ.
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.

No comments:

Post a Comment