uzikilon/backbone-poller — pull request #20 by khirakawa (2013-07-23 21:59:09+00:00)
Title: moved delayed run to start function

Hi,

I have the following code to restart polling on error.

```javascript
var options = {
delayed : true
};

var poller = Poller.get(model, options);

poller.on('error', function(model){
poller.start();
});

poller.start();
```

The delay is needed so that `fetch` does not get called in rapid-fire when errors are continuously thrown. However, the above code does not work as expected because `options.delayed` gets reset to false in `delayedRun`. A workaround would be to set `poller.options.delayed = true` inside the error handler, but it's a bit hacky.

I dug around the source code and noticed that we can pull the `if (poller.options.delayed)` check outside of `run()` and place it inside `start()`. This way, 1) it is only checked once, 2) the code doesn't modify user passed options, and most of all, 3) fixes the above problem.