On Oct 25, 9:22 am, Thomas Broyer <[email protected]> wrote:
>
> I'd rather use the following, though I understand why the
> LoginView.Presenter interface could help with mocking (it's easier to
> mock the view then, because you don't have to mock HasClickHandlers
> and eventually HandlerRegistration and ClickEvent):
> LoginPresenter.View interface:
> String.getName()
> String getPass()
> HasClickHandlers getSignInButton()
>
> The LoginPresenter constructor looks like:
> LoginPresenter(LoginView view ...and some other parameters...)
> this.view = view;
> view.getSignInButton().addClickHandler(new ClickHandler() {
> public void onClick(ClickEvent event) {
> tryToLogin();
> }
> });
Thanks for your feedback! I see yet another option, substituting a
callback injection for the "this" injection:
LoginPresenter.View interface:
String getName( );
String getPass( );
AsyncCallback<Object> setTryToLogin( );
then the constructor is:
LoginPresenter(LoginView view ...and some other parameters...)
this.view = view;
AsyncCallback<Object> callback = new AsyncCallback<Object> ( ) {
// onSuccess connect to the login service and try to login
// we won't need onFailure
}
view.setTryToLogin(callback);
and on clicking the "Login" button, the view would just execute
callback.onSuccess(null);
I'm wondering if that would be easier to mock...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---