This adds a method to the event class which allows the user to register a callback function to be invoked when the event reaches the specified state (e.g. when it completes).