Hi all,
lets look at the code:
public class MyView implements IMyView {
Button click;
.....
public HasClickHandlers getClick(){
return click;
}
}
public class MyPresenter {
public interface IMyView {
public HasClickHandlers getClick();
}
private IMyView view;
public MyPresenter(IMyView view){
this.view = view;
bind();
}
private void bind(){
view.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent e){
Window.alert("heellllo");
}
}//binds end
}// class ends
//(We are not using Activities or any MVP framework)
ok tats it. Now in applicaton the view is singleton. but the presenter are not, so they are made as and when needed like :
MyPresenter p = new MyPresenter(view); //view is singleton throughout the application; assume getting it by some factory
Now suppose after a while if I have created 10 MyPresenter instance that will add 10 clickHandler to button "click" . So one click event will be handled 10 times by 10 different handlers.
I can see here it as happening when click the button I get 10 times alert window.
So where I misunderstood the MVP architecture, what I am missing..... please help
Thanks in advance.