October 2019
Intermediate to advanced
434 pages
11h 54m
English
Event-driven programming is a programming paradigm in which the logical flow and computation are controlled by events such as user-generated actions.
With event-driven programs, computation is typically only performed in response to some event. That event could be a user clicking a mouse or pressing a key on the keyboard, or it could be a sensor returning a new value. While events are not being processed, the program is idle, probably iterating through a main event loop that continues the operation of the program and regularly checks for new events to process.
The following snippet illustrates what a basic event-driven loop might look like:
var isRunning = truewhile (isRunning) { val newestEvent = events.poll()
Read now
Unlock full access