View Single Post
02/20/23, 03:40 AM   #10
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
EVENT_MANAGER:UnregisterForEvent(BS.Name, _G.EVENT_ADD_ON_LOADED)

Should always be done unless you need to read other addons' EVENT_ADD_ON_LOADED too!
This event fires for each of your addons and libraries and as your's is found you can stop it by unregistering in 99%.

EVENT_PLAYER_ACTVATED fires after login the first time, as chat is ready.
You should register it at your EVENT_ADD_ON_LOADED and either keep it registered, because it also fires at a reloadUI, zone change with a loading screem (port into dungeon e.g., or port to someone in another zone ...).
Or you unregister it and it will only fire once after login then.
Depends on your usecase and needs.

Register, unregister, re-register is not needed each time an event fires! If you want events to be triggered each time it fires just keep it registered then. But Make sure the events are not registered before your EVENT_ADD_ON_LOADED was fired, as else you might run into issues where your event's callback function is executed but your code was not ready yet as it will be initialized at your EVENT_ADD_ON_LOADED first.
  Reply With Quote