I don't know if i am missing something, but, why yo don't create a
clientFactory in order to get the View?

In that way you only create the view once and you avoid the problem of
having multiple handlers attached.

2012/9/14 Aryan <[email protected]>

>
>
>
>
>
>
> On 14 Sep, 14:21, stuckagain <[email protected]> wrote:
> > Why does the view need to be a singleton ?
>
> I guess why I am having view as singleton is having better performance
> as I see views are expensive to create.
> Not creating em everytime saves operation deep down like
> "Document.create.... -> appendChild..... and so the DOM manipulation
> that saves time.....
>
> >
> > Anyway, when you are done with the presenter, then you need to tell it
> so.
> > In that case it can unregister any installed handlers.
> >
> > David
> >
> >
> >
> > On Thursday, September 13, 2012 8:09:30 PM UTC+2, Aryan wrote:
> > > 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 "c*lick" . 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.- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> 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.
>
>


-- 
El precio es lo que pagas. El valor es lo que recibes.
Warren Buffet

-- 
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.

Reply via email to