View Single Post
05/27/14, 04:24 PM   #22
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by lyravega View Post
What I really don't understand about creating custom events is, what do you watch? On examples, all custom events that I've seen are linked to "OnSomethingHappened" stuff. Since I am not working with UI (at all), I cannot grasp what else you can use instead of "OnSomethingHappened" stuff.

And don't bother, I won't be able to till I see some other examples, I learn better with dissecting stuff and inspecting them bit by bit
Events allow other code (that you do not need to know about in advance) to react to something happening in your code.
They do not know what we write in our OnUIUpdate Event Handlers. And still our Handlers are able to react to the event (specificalyl the Update/Draw phase of the UI).

A second aspect is that Events do not need to follow the usual rules for declaration. You can "Fire" an event in code, long before you have any Callback defined (much less registerd). With normal function calls you need to have the code you call defined before you call it*. Also you can register an arbitrary amount of different Callback functions to one Event.

*Wich can get you into a Egg and Chicken Paradox if A depends on B, B on C and C on A. And yes, I managed to programm myself into one of those.
  Reply With Quote