I ran into the same problem in several different GWT applications that I developed using the Ray Ryan approach. My preferred solution is to create a Singleton “session object” that saves the state of this part of the application. In your example, it might look like this:
interface EditPersonSession {
void fetchPerson(PersonId id);
PersonDetails getCurrentPersonDetails();
void updatePersonDetail(PersonDetail<?> detail);
void updatePetDetail(PetDetail<?> detail);
void updateAddressDetail(AddressDetail<?> detail);
void save();
}
All three speakers contain a reference to the session object (possibly entered by Gin). Whenever the user interface (view) is manipulated by the user, the host associated with this view immediately pushes the state to a shared session object. For example, inside EditAddressPresenter:
view.getStreetNameTextBox().addValueChangeHandler(new ValueChangeHandler() {
void onValueChange(ValueChangeEvent<String> event) {
editPersonSession.updateAddressDetail(new StreetNameAddressDetail(event.getValue()));
}
}
, , . . , EditPersonPresenter:
view.getSaveButton().addClickHandler(new ClickHandler() {
void onClick(ClickEvent event) {
editPersonSession.save();
}
}
, , .
, , , ( , ), , ( Singleton HandlerManager). PersonDetails .