View Single Post
04-24-14, 06:54 PM   #6
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
This can also be done without a table by using select or a recursive function.

As for efficiency, I can't say whether the overhead of the function calls would outweigh dealing with recycling a table. It's probably simpler to write, at any rate.
Lua Code:
  1. local function ProcessFrames(...)
  2.     local n = select('#', ...)
  3.     for i = 1, n do select(i, ...):UnregisterEvent('ZONE_CHANGED_NEW_AREA') end
  4.    
  5.     -- Do stuff
  6.    
  7.     for i = 1, n do select(i, ...):RegisterEvent('ZONE_CHANGED_NEW_AREA') end
  8. end
  9.  
  10. ProcessFrames(GetFramesRegisteredForEvent('ZONE_CHANGED_NEW_AREA'))
More importantly, I'm unsure if there's potential for a race condition by doing this.

What happens if the event fires while you're unregistering frames?
  Reply With Quote