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/

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <pre>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.
  • E-Mail addresses are hidden with reCAPTCHA Mailhide.

More information about formatting options

CAPTCHA
Complete this form and then pat yourself on the back.