Quote Originally Posted by ZorbaTHut View Post
Quote Originally Posted by Malvir View Post
I have some questions/feedback about the intended usage of some of the events.Specifically...1) Should we be loading our Saved Variables on the SavedVariables.Load.Begin or SavedVariables.Load.End events? On one hand it could be that the variables are loaded from the file starting at .Begin, but it doesn't complete until .End. If that were the case, then attempting to load Variables on the .Begin event would be incorrect. On the other hand it could be that Begin is the first time the variables have been loaded from file and it starts to run the handlers for loading and End is when all of the handlers are expected to be done.2) Same question for SavedVariables.Save.Begin or SavedVariables.Save.End.This one seems a little more intuitive, as writing out data at the end of savedVariables Saving doesn't seem right, but want to confirm.3) As a general rule, should we be attaching to the *.Begin events?4) If so, what is the intended use for the *.End events?5) What is the intended purpose of the Event.Addon.Finalizing event? When and how does that event get fired?6) What is the difference between Addon.Starting and Addon.Load ?7) Is Addon.Starting related to Addon.Finalizing?8) Can you tell us the proper sequence of Events that happens when an addon is loaded & started? In what order do those events occur?9) Should we be utilizing the Addon.Load event to do some first-load initializaiton? Or should we use Addon.Starting for that?10) When I keyed on the SavedVariables.Load.Begin event it fired 3 separate times when I did a /reloadui. I also had 3 total addons installed. Is that event being fired for each addon? If so, should we be filtering the event to our specific Addon? I only expect it to fire once, but that is not what I am seeing.
In general, Begin events are provided so that, if you need to do something immediately before the thing occurs, you can. The End event will follow immediately after and will be the first event after the thing occurs. In the case of SavedVariables you'll want to use the End event, as that will be the first opportunity after things have been loaded. I can't think of a reasonable use for either the SavedVariables.Load.Begin or the SavedVariables.Save.End events, but they're provided anyway just for completeness's sake.Most of the Addon.* events include the name of the addon as the first parameter, which is why they're being called multiple times.A few of these functions are being changed in the near future, so I'm describing what they will look like soon.The addon loading flow looks like this:
Code:
-- Addon.Startup.Begin() -- This event doesn't exist, because if it did, it would be triggered before any addon code, and would therefore be useless. But it conceptually does because there's an Addon.Startup.End().For each addon:  Addon.Load.Begin(addon) -- Signals that an addon is about to start loading. If you want to hook functions in order to change the behavior of that addon, this is the time to do it.  (All of that addon's files are loaded here)  Addon.SavedVariables.Load.Begin(addon) -- Signals that SavedVariables are about to be loaded.  (SavedVariables get loaded here)  Addon.SavedVariables.Load.End(addon) -- Signals that SavedVariables have just been loaded.  (If we add more loading stages to addons, they'll either occur here, or before Addon.SavedVariables.*)  Addon.Load.End(addon) -- Signals that the addon has completed its loading sequence.Addon.Startup.End() -- Signals that all addons have completed their loading sequence. At the moment, this is Addon.Starting().(This is where the player plays the game)Addon.Shutdown.Begin() -- Signals that the addon system is about to be shut down. At the moment, this is Addon.Shutdown().For each addon:  Addon.SavedVariables.Save.Begin(addon) -- About to save an addon's savedvariables.  (SavedVariables get saved here)  Addon.SavedVariables.Save.End(addon) -- Finished saving an addon's savedvariables.Addon.Shutdown.End() -- The last event sent before the addon environment goes away. At the moment, this is Addon.Finalize(). Also, at the moment, this is useless to hook since an addon can no longer do anything useful.
Jump to post...