Events

Top  Previous  Next

An event is something which happens to an object. Plain and simple. A fridge might have door object with an on_door_open event, and a paper shredder might have a detector object with an on_paper_detected event.

Events are a core concept in Tibbo Basic. They are the primary way in which code gets executed.

The target device maintains an event queue. All events registered by the system go into this queue. On the other end of the queue, the Virtual Machine takes out one event at a time and calls an event handler for each event.

Event handlers are subroutines in your code which are 'fired' (executed) to handle an event. Often, event handlers contain function calls which run other parts of the program.

While processing an event, other events may happen. These events are then queued for processing, and patiently wait for the first event to complete before beginning execution.

All Tibbo Basic programs are single-threaded, so there is only one event queue. All events are executed in the exact order in which they were queued.

It may sometimes seem that some events should get priority over other events. This functionality is not supported under Tibbo Basic. This is not crucial, as events tend to execute very quickly, and the queue ensures events are not forgotten.