title: RequireJS - Return after onready
body: <p>I have a RequireJS module and I want to only return an object after it's onReady() event has been called.</p>
  
  <pre><code>define([
  'kendovendor', 
  'TodoDB',
  'jaydatakendo'
  ], function (kendo,tododb,jdvend) {
  
  
      var onlinedb = new Avcheck.Layered.Model.AvCheckContext({
          name: 'oData',
          oDataServiceHost: '/WcfDataServiceTest.svc'
      });
  
      var offlinedb = new Avcheck.Layered.Model.AvCheckContext({
          name: 'webSql',
          databaseName: 'TodoDB'
      });
  
  var fullDB;
      offlinedb.onReady(function () { 
           fullDB = onlinedb.AChecklistComplete.include('AChecklistTop').include('Aircraft').include('Aircraft.Vendor').asKendoDataSource();
  
  //calling this inside onReady() returns nothing as there is a timing issue
   return {
          onlinedb: onlinedb,
          offlinedb: offlinedb,
          FullDB: fullDB
      };
  
  
      });
  
  
  
  });
  </code></pre>
  
  <p>The reason for this is that the JayData include() will only work after the database is ready. But another module is using this module as a requirement, and this module returns nothing. If I call return outside of onReady(), then it returns a valid object, but FullDB is not set properly.</p>
  
  <p>How can I set up RequireJS to work nicely with an objects onready() event? Thanks.</p>