use jQuery's Deferred object to handle async app state setup