Vizzuality/gfw — pull request #584 by eightysteele (2014-06-25 23:24:04+00:00)
Title: MVP example for map + layers = BOOM 

OK dudes, this is looking pretty solid. I hacked the MVP example for map and layers like we talked about. On HC let's deeeefinitely talk through how different scenarios work haha. In the meantime here's a quick walkthrough.

User loads the site at the /map/3/15.00/27.00/ALL/terrain/loss route and then...

1. Router creates the MapView then publishes a "Place/go" event passing in the above route parameters
1. MapPresenter responds and has MapView update the map and layers in the UI using the parameters
1. MapView creates layer views (in this case the UMDLossLayerView) and adds them to the map
1. Layer view presenters (in this case UMDLossLayerPresenter) listen for events like "Timeline/change"
1. If a "Timeline/change" event is published with the new dates, the layer presenter has the layer view redraw

All of this is working if you `foreman start` this thing. And look how painless those tests are! :D

Relevant modules:

[MapView](https://github.com/Vizzuality/gfw/blob/feature/refactor-june-mvpboom/app/assets/javascripts/map/views/MapView.js)
[MapPresenter](https://github.com/Vizzuality/gfw/blob/feature/refactor-june-mvpboom/app/assets/javascripts/map/presenters/MapPresenter.js)
[MapPresenter Test](https://github.com/Vizzuality/gfw/blob/feature/refactor-june-mvpboom/jstest/spec/MapPresenter_spec.js)

[UMDLossLayerView](https://github.com/Vizzuality/gfw/blob/feature/refactor-june-mvpboom/app/assets/javascripts/map/views/layers/UMDLossLayerView.js)
[UMDLossLayerPresenter](https://github.com/Vizzuality/gfw/blob/feature/refactor-june-mvpboom/app/assets/javascripts/map/presenters/UMDLossLayerPresenter.js)
[UMDLossLayerPresenter Test](https://github.com/Vizzuality/gfw/blob/feature/refactor-june-mvpboom/jstest/spec/UMDLossLayerPresenter_spec.js)