title: How to convert callback sample to deferred object?
body: <p>I have a function that accepts a callback function where I pass the data back in. Can this converted to a deferred object for better practice?</p>
  
  <p>Here is what I got:</p>
  
  <pre><code>    var chapters;
      var getChapters = function (fnLoad) {
          //CACHE DATA IF APPLICABLE
          if (!chapters) {
              //CALL JSON DATA VIA AJAX
              $.getJSON('/chapters.txt')
                  .done(function (json) {
                      //STORE DATA IN LOCAL STORAGE
                      chapters = Lawnchair(function () {
                          this.save(json, function (data) {
                              //CALL CALLBACK ON DATA
                              fnLoad(data);
                          });
                      });
                  });
          } else {
              //RETURN ALREADY CREATED LOCAL STORAGE
              chapters.all(function (data) {
                  //CALL CALLBACK ON DATA
                  fnLoad(data);
              });
          }
      };
  </code></pre>
  
  <p>Then I simply use it like this:</p>
  
  <pre><code>this.getChapters(function (data) {
      console.log(data);
  });
  </code></pre>
  
  <p>How can I use it like a promise though while maintaining the cache approach?</p>
  
  <pre><code>this.getChapters().done(function (data) {
      console.log(data);
  });
  </code></pre>