I'd like to see an optional special case (a "pseudo-event") added to the event structure called the 'All Events' case. The 'All Events' case would include code that was executed before each event. Events would be handled as they are now (normal and filter events) except that if the 'All Events' case existed, an instance of the 'All Events" event would be inserted before every event dispatched. (I'm gonna call it the AE from now on...)
In essence it would be a way to execute code before each and every event that is handled by the user - including filter events. An instance of the AE event would be created and queued into the event chain each time an event occurred - before that event was enqueued. The data passed in to the AE case would be the name of the event that the AE event was generated for in addition to the data passed to that event.
A new property, "Add All Events case'" could be added right before "Add event case" in the events sturcture right-click context menu. Only one AE case could be added to an event structure, and it would always appear first in the event order. Adding an AE event would be optional.
The primary purpose of this for me would be to facilitate event logging. We leave an execution trace of our code in an HTML report so that when errors occur we can determine how we got there. With the 'All Events' functionality, instead of having to place logging code in every event case, I could just put it in the AE case, put logging code there, and an instance of that event would be created before every 'normal' event to log the normal event before it was handled. Since the data that the AE event receives is the same as the event that will follows, plus that event's name, logging is a snap.
The AE case should be inserted in the event queue as a filter event. As a filter event, the AE case would allow event discard functionality so that even filter events could be discarded before they are called.
Implementing the AE case as a filter event has the side-effect that it would make the development of more complicated state machines based on the event mechanism easier because you could enable or disable entire groups of events by using the event discard functionality in the 'All Events' case, in essence turning on and off entire portions of your state machine.
Note that two AE events could actually execute back-to-back - if the first AE event discarded the event it preceded.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any idea that has not received any kudos within a year after posting will be automatically declined.