Custom events are a fact of life. The Observer Pattern is indespensable. YUI supplies a custom event object - but to get it, you’ve got to include about 8 kilobytes of library in your project. Granted, YUI supplies much, much more than just an event object - but sometimes you don’t need all that. You just need a way for objects to talk to each other. Introducing a bare-bones event object that’s good enough for most situations! It’s not as flexible as YUI’s, but it gets the job done.
Posts Tagged ‘closures’
Simple Javascript Custom Event Object
Monday, March 30th, 2009Private object members via closures
Sunday, March 1st, 2009In almost any object oriented language, you can define access levels for variables in objects. You can in JavaScript, too, but it’s not quite as clear cut as adding a “public” or “private” key word to your object definition. Once you understand how closures work, though, it’s pretty obvious how to implement private member properties and methods. (more…)