Broadcaster Library for Processing

The Broadcaster Library adds a Broadcaster class that provides event dispatching and listener management. Put simply, when you create an instance of Broadcaster, you can associate other objects with it, Listeners, and then call methods on all of those listener objects without having to keep track of them or loop through an array. The prime example is calling a draw() event on a group of objects without making a huge loop in the draw event. The broadcaster automatically takes care of it for you. Just tell the broadcaster to listen for processing's draw event, and you're ready to go.

In addition to familiar methods like draw, you can also call any method on the listener objects at any time. Say you have a flock of particles bouncing around and you want them all to turn and converge on the mouse when the user clicks. Using Broadcaster, you can simply broadcast an event to all the particles in a single line of code.

From a program design point of view, Broadcaster helps you loosely couple groups of objects so that changing the details of one doesn't interfere with the behavior of other objects it interacts with.