API for executing callback functions on events or timeouts
