Vizzuality/gfw — pull request #582 by eightysteele (2014-06-24 04:49:40+00:00)
Title: Proposed change to Model-View-Presenter

Yo dudes, this PR proposes a suuuuuper minor change from the current presenter/mediator arch to the model-view-presenter. :D

http://en.wikipedia.org/wiki/Model-view-presenter

Let's look at an example because who wants to RTFM. Here's the proposed MVP rig for the analysis button:

View - [AnalysisButtonView](https://github.com/Vizzuality/gfw/blob/feature/refactor-june-mvp/app/assets/javascripts/map/views/AnalysisButtonView.js)
Presenter - [AnalysisButtonPresenter](https://github.com/Vizzuality/gfw/blob/feature/refactor-june-mvp/app/assets/javascripts/map/presenters/AnalysisButtonPresenter.js)
Presenter test - [AnalysisButtonPresenter_spec](https://github.com/Vizzuality/gfw/blob/feature/refactor-june-mvp/jstest/spec/AnalysisButtonPresenter_spec.js)

Basically:

1. Views have their own presenter (no more global presenter, no more mediator)
1. Views have functions to update their display (used by the presenter)
1. Presenters have functions to handle UI events (used by their view)
1. Views basically don't do anything so now they don't need to be tested (this is HUGE)
1. Unit testing is waaaaay more sane and the app code is waaay simplified.

What you guys think? :D You probably have a few questions hh. There are a few differences from our current arch. Let's go through it here in comments or in HipChat BOOM haha.