marionettejs/backbone.marionette — pull request #1793 by sebslomski (2014-08-31 11:27:43+00:00)
Title: Wait for View.destroy to finish via promise before showing a new view

Hi,

# Use Case
I've got this use case in almost every project:
1. Show a popup
2. Click a button in the popup, which closes the popup for about 0.5s (fade out)
3. The click triggers an other popup to be shown

# Problem
The current Backbone.Marionette version does't respect any async timing in the `destroy` function of a view. This leads in my use case to hiding the first popup immediately without any animation (the animation is defined in the `destroy` function).
Example: http://jsfiddle.net/M5J8Q/1514/

# Solution
I extended the `show` function of the region to work with promises. A view's `destroy` function can now return a promise. The region waits for the promise to be resolved before showing a new view.
Example: http://jsfiddle.net/M5J8Q/1516/

**Important**
This code is only a brief example, first and foremost I want to put this into discussion.