Events

One way to execute code when something happens is to use events. You can think of an event like the music of an ice cream truck. Everyone can hear the music, but not everyone cares. If you do care, you will react in some way when you hear the ice cream truck music (run for your wallet, then run to the truck, then pretend you’re buying ice cream for a kid and not for yourself). If you don’t care, you can just ignore the music.

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.