ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   EVENT_MANAGER:RegisterForUpdate (https://www.esoui.com/forums/showthread.php?t=4222)

circonian 01/23/15 08:27 PM

EVENT_MANAGER:RegisterForUpdate
 
Questions about the Event Manager:

Does it matter if you re-register something for update (to change it), without unregistering the old one first?
Lua Code:
  1. -- Register something for update
  2. EVENT_MANAGER:RegisterForUpdate("Something", ...)
  3.  
  4. -- Re-register it to change it, without unregistering the old one
  5. EVENT_MANAGER:RegisterForUpdate("Something", ...)

Does it really matter if you try to UnregisterForUpdate if it isn't registered?
Lua Code:
  1. -- unregister it (maybe this is done in normal code somewhere & we know its registered
  2. EVENT_MANAGER:UnregisterForUpdate("Something")
  3.  
  4. -- But maybe in the settings menu we don't know if its registered, so unregister it just in case
  5. EVENT_MANAGER:UnregisterForUpdate("Something")

Is there some way to check to see if something is registered with the event manager?
Besides creating a variable myself to track whether or not you have "Something" registered for update?

circonian 01/28/15 09:26 PM

Doh, I didn't even think about checking it myself like this:
Lua Code:
  1. EVENT_MANAGER:RegisterForUpdate("RegisterTest", 3000, function() d("RegisterTest 1") end)
  2. EVENT_MANAGER:RegisterForUpdate("RegisterTest", 3000, function() d("RegisterTest 2") end)

Only outputs: RegisterTest 1
So I guess you can't reregister it to update it. You have to unregister it & then reregister it.

Which also lead me to figuring out it returns true, false if it gets registered or not:
Lua Code:
  1. local bRegistered1 = EVENT_MANAGER:RegisterForUpdate("RegisterTest", 3000, function() d("RegisterTest 1") end)
  2. d(tostring(bRegistered1))   -- prints true
  3.  
  4. local bRegistered2 = EVENT_MANAGER:RegisterForUpdate("RegisterTest", 3000, function() d("RegisterTest 2") end)
  5. d(tostring(bRegistered2))   -- prints false

Although other problems also can cause a return of false:
Lua Code:
  1. -- the function is nil
  2. local bRegistered3 = EVENT_MANAGER:RegisterForUpdate("RegisterTest", 3000)
  3. d(tostring(bRegistered3))   -- prints false

So I guess you can't rely on a return of false to know that something is already registered.
I'm still trying to figure out a way to determine if something is already registered or not.


All times are GMT -6. The time now is 02:15 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI