Javascript Daemon Manager Class

I found that I often have a little DHTML widget or something that might show up multiple times on the same page. If you approach that in an object-oriented way, that means that you’ve got a lot of little instances (daemons) running around handling each one, right? Then, I’d write a “manager” that would provide an interface to the “daemons,” to automate the process of creating and dealing with the daemons. That also means that you can put a bunch of the code in the manager, since you really want to keep the daemons as lightweight as possible, if there’s going to be a lot of them. (Of course, proper use of prototype inheritance will make each daemon rather small, anyhow.)

Well, I wrote the same type of code multiple times, and that always means its time for abstraction. So, a generic manager class that can be applied to any miscellaneous daemon class. You send it a class, and it’ll create a manager. It automagically provides “pass-through” events for any CustomEvents that the daemon class may create. Also, whenever any CustomEvent on any of the daemon fires, the manager will fire onDaemonEvent.

Comments, criticism, suggestions, etc., more than welcome.

Go get it!

Leave a Reply

Comments are moderated like crazy using a variety of plugins. There is a very high likelihood that your comment won't show up right away, especially if you have never commented here before, but it was not deleted.

Please be patient, and do not post your comment more than once. It will show up once it is approved.

You must be logged in to post a comment.