How do you implement a class that can subscribe to and emit events that trigger attached callback functions?

Technical