title: Backbone.js Timer - useless setInterval call
body: <p>Although I searched for a solution, i did not found one for my problem. Im using cordova and jquery mobile. there are fired to events: document.ready and the device ready of cordova. i want to check the loading states by checking to booleans, to know when to start the main application.</p>
  
  <p>so have a look at my code:</p>
  
  <p>First: The first js-File loaded:</p>
  
  <pre><code>function checkReadyStates() {
      if(domReady &amp;&amp; cordovaReady) {
          timer.stop();
          start();
      }
  }
  
  var domReady = false;
  var cordovaReady = true;
  var timer = new TimerModel({interval : 50, method : checkReadyStates});
  timer.start();
  
  // get notified when DOM is loaded
  $(document).ready(function() {
      ConsoleController.info('Document ready.');
      domReady = true;
  });
  
  // get notified when cordova is ready
  document.addEventListener('deviceready', function() {
      ConsoleController.info('Cordova loaded.');
      cordovaReady = true;
  }, false);
  </code></pre>
  
  <p>Second: The TimerModel:</p>
  
  <pre><code>define(['backbone'],function(Backbone) {
  
  var model = Backbone.Model.extend({
  
      defaults: {
          timerObject : null,
          active : false,
          interval : 1000,
          method : null,
      },
  
      // init timer
      initialize : function() {
          _.bindAll(this, 'start', 'stop'); // context bindings
      },
  
      // starts the timer with given interval
      start : function() {
          if(!this.active) {
              this.active = true;
              this.timerObject = setInterval(this.method, this.interval);
          }
      },
  
      // stops timer
      stop : function() {
          this.active = false;
          clearInterval(this.timerObject);
      }
  
  });
  
  // return the timer model
  return model;
  
  });
  </code></pre>
  
  <p>Hope someone's able to help. Thanks!</p>