toddmotto/atomic — pull request #6 by Matthew2602 (2014-04-21 09:12:58+00:00)
Title: Allow for multiple .success() and .error() callbacks

Currently, the script only allows for a single success callback and a single error callback to be passed through the `.success()` and `.error()` methods the `xhr` functions returns. If an additional success or error callback is given, only that callback ends up being run – the previous callback is silently thrown away and is never run.

**That's really problematic**.

For example:

```javascript
atomic.get("/").success(function() {
console.log("foo");
}).success(function() {
console.log("bar");
});
```

The script takes in and stores the first callback, but when it takes in the second callback, it assigns it over the first callback, silently throwing it away. `"foo"` is never logged to the console – only `"bar"` is.

My commit makes the script store the callbacks passed into it through `.success()` and `.error()` in an array, and once the request has finished and the script has determined it to have either succeeded or failed, it iterates over the relevant array, calling each callback stored.

(Side note: It appears that `grunt` wasn't run in the last 4 commits, and as a result, the changes in my commit to the files in the `dist` directory include the changes made in the last four commits. My apologies.)