简体   繁体   中英

Should Presenter handle all events of View in MVP design architecture in Android?

Suppose I have a Button in my Activity which shows me a Toast message when it is clicked. Now my question is, should I notify the Presenter when my button is clicked and the Presenter should decide what the View should do or it is not required to notify the Presenter and my View can itself show a message?

Even though the presenter isn't (currently) supposed to provide any data from the model to be shown in Toast upon a button click, it is still a good approach to notify the presenter by the following reasons:

  • the view and presenter behaviour might be tested ( instrumentation and unit );
  • you might want to provide data from the model to be shown in Toast in the future. Such a modification would require less effort.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM