event handler similar to the node.js eventEmitter class