Could be useful. You might use:
a) a type for events (field event$, for example)
b) a type for active events (also, field event$)
c) a type for event registrations (field event$, field callback ??? - see below)
d) a function to fire off an event (would create a new object of the active_event type)
e) a function allowing an object to register as a listener for an event (create a new object of the event_registration type)
f) an event manager, called in the main loop, that detects all events (loops "for each" on the active_event type), calls all event handlers registered for each active event and then deletes that event from the active_events queue.
The trouble seems to be the callbacks - does Blitz allow passing the name or address of a function as a parameter, storing it in a field of an "event_registration" type, and calling that function to pass the notification of an event to a registered object?
There's my two bits on theory. I don't know if Blitz allows passing a function as a parameter, or supports callbacks.
a) a type for events (field event$, for example)
b) a type for active events (also, field event$)
c) a type for event registrations (field event$, field callback ??? - see below)
d) a function to fire off an event (would create a new object of the active_event type)
e) a function allowing an object to register as a listener for an event (create a new object of the event_registration type)
f) an event manager, called in the main loop, that detects all events (loops "for each" on the active_event type), calls all event handlers registered for each active event and then deletes that event from the active_events queue.
The trouble seems to be the callbacks - does Blitz allow passing the name or address of a function as a parameter, storing it in a field of an "event_registration" type, and calling that function to pass the notification of an event to a registered object?
There's my two bits on theory. I don't know if Blitz allows passing a function as a parameter, or supports callbacks.