marionettejs/backbone.marionette — pull request #1069 by dmytroyarmak (2014-03-29 15:15:08+00:00)
Title: Async module initializers and finalizers

It is implementation of module/application async initializers and finalizers. It was discussed here: #792.

If your initializer or finalizer is async you should return promise from it so module/app will be able to trigger `start` or `stop` event at correct time. As result `Marionette.Application#start`, `Marionette.Module#start` and `Marionette.Module#stop` now returns promises.

This changes are backward compatible so It can be merged before `v2.0`.

I've used $.Deferred and $.when inside to work with async actions in maintainable and simple way. Also `Marionette.Callbacks` has been rewriting to support async callbacks.

If you call `stop` when your app is starting it will be stopped after starting is finished.

Here is example of async application starting and stopping: http://jsbin.com/sejukike/5/edit?js,console