Creating an event
What's that timmy? You're exposing your API to someone else, and they want convient handy-dandy events?! No problem! As with everything in Boo, its dead simple to get up and running within moments with the event keyword.
Aww, yeah! Now you can use it like any other event!
(it prints out "Tah CLICKED!" if you're curious)
By now you're probably wondering what "EventHandler" is. In .NET, they are commonly referred to as delegates, a type of event that can be subscribed to by multiple functions, as long as each function has the same method signature as the delegate. An "event" is a special kind of delegate that has some rules:
- It can't be called from outside its declaring class.
This keeps sneaky coders from invoking an event from somewhere else and potentially messing things up. Leaky boats are bad!
Suppose, though, you want a ham sandwich on rye, or you want to expose a unique kind of event that has its own unique arguments. Here's another code sample to whet your apetite: