Event Listener Example

I wrote this to demonstrate the observer design pattern. There is one object (window) which dispatches an event when the “shake” button is clicked. All shape objects listen to the window object for a “shake” event. When an object hears a “shake” event it will check to see if it meets the credentials and if it does then it will “shake”.

Note: In order to get this example to work you’ll have to visit the actual fiddle: http://jsfiddle.net/zyvw9gxt/