I can not find how to implement this (I apologize for writing a freestyle):
//assign the event handler for the object "myObj"
myObj.onMyEvent = //do something
//if something happened somewhere, then run the event
MyEvent.fire();
The idea is that we are calling (generating) some kind of custom event (MyEvent). We have an object "myObj" that is able to recognize the appearance of "MyEvent" and somehow (in its own way) respond to it. In addition, we have other objects (different types) that (in their own way) respond to "MyEvent".
I know that there is a "observer pattern", but I cannot find a specific implementation.
Could you tell me where to read about it? Or is it impossible in nature? Or is this done in a completely different way?
Update 1: no JS libraries, please (jQuery, Prototype, YUI, ...)