Thanks for the comparison link. Interesting read.
Sent from my iPhone On 3 Jan 2011, at 21:15, Miller Medeiros <[email protected]> wrote: > I've created a comparison between different observer implementations: > https://github.com/millermedeiros/js-signals/wiki/Comparison-between-different-Observer-Pattern-implementations > - and also an implementation called "JS-Signals": > http://millermedeiros.github.com/js-signals/ > > I believe that most JS developers already used the observer pattern, the name > makes it sound more complex than it is... - the DOM 2 events are based on the > observer pattern: > document.getElementById('myAwesomeDiv').addEventListener('click', > handleAwesomeClick, false); > > you can use custom events for any kind of "events" that may happen to your > application - state/section changes, user interactions, etc... instead of > calling a function directly you dispatch/broadcast an event and the listeners > handle it... that way you can add/remove handlers without refactoring your > code and have as many actions as you want for the same event.. > > if you want to use a more traditional kind of observer (similar to the DOM 2 > EventTarget) check: > https://github.com/millermedeiros/MM_js_lib/blob/master/src/EventDispatcher.js > - if your object extends EventDispatcher it will be able to add/remove > event listeners and dispatch custom events. > > cheers. > > -- > Miller Medeiros | blog.millermedeiros.com > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
