colinbdclark/Flocking — pull request #25 by TheAlphaNerd (2012-08-16 08:52:35+00:00)
Title: Updated Scheduler to release events on .clearRepeat()

While attempting to get the arpeggiator working I notice a problem with the scheduler. Specifically the events being triggered by the asynch interval worker were not being released when .clearRepeat() was called.

While this may have been an intentional design, it cause a really annoying result, specifically that when attempting to schedule a new event at the same rate both the new event and old event would fire

The below code segment gives an example of what could cause the above mentioned edge case

```javascript
test = function () {
console.log("test")
};
test2 = function () {
console.log("test2")
};
async = flock.enviro.shared.asyncScheduler;
async.repeat(1000, test);
async.clearRepeat(1000, test);
async.repeat(1000, test2);
```

While my solution may be a bit hacky... I think it is the write direction. I created an array to store active listeners in (stored as object with both listener and value. Then I created a new function called removeFilteredListener, which calls $.each on the array and removes a listener if there is one matching the provided details.

As far as I can tell this patch works, but I suspect it needs to be refactored.