Add Deferreds
Get introduced to jQuery deferreds and learn how deferred objects are different from the promise function in Marionette.
Our goal is to find a way to wait until the contact data has been returned before instantiating our view.
Using jQuery deferreds
One way to achieve this is by using a callback function, which doesn’t scale well. What if we need to wait for multiple data sources to be returned before displaying them? Recursively providing callbacks to callbacks starts getting very difficult, very fast.
Instead, we’ll use jQuery deferreds, which will allow us to use a much cleaner mechanism to wait for the required data before instantiating a view. Let’s use a deferred object to return a promise
from our contact:entity
handler:
Get hands-on with 1400+ tech skills courses.