AaronAcerboni/PubSub.as — comment on commit d2c4dc71dd835e944eca4bc19d3b8e5986a6336f
File: PubSub.as line 90
By aron:

Hey Aaron!

Be careful when modifying arrays using .splice() as this modifies the actual array instance rather than creating a new copy like slice(). If remove() gets called in the middle of publish() when you're looping over this array, the array will change and you're going to get an error. A good example of this is a "once" callback that unbinds itself in it's handler.

This is an error in the original JavaScript library too but I thought I'd let you know :) I've added an example to JSBin (http://jsbin.com/avusog/) check the console, you should see an error. There are a few fixes, the simplest is to clone the array in publish() before you start looping over it, then you know it will never change.