diff modules/ReAction_ModuleTemplate/ReAction_ModuleName.lua @ 63:768be7eb22a0

Converted several ReAction APIs to event-driven model instead of 'call-method-on-all-modules' model. Cleaned up a number of other architectural issues.
author Flick <flickerstreak@gmail.com>
date Thu, 22 May 2008 22:02:08 +0000
parents 21bcaf8215ff
children da8ba8783924
line wrap: on
line diff
--- a/modules/ReAction_ModuleTemplate/ReAction_ModuleName.lua	Tue May 13 16:42:52 2008 +0000
+++ b/modules/ReAction_ModuleTemplate/ReAction_ModuleName.lua	Thu May 22 22:02:08 2008 +0000
@@ -14,7 +14,7 @@
   -- mixins go here
 )
 
--- module methods
+-- handlers
 function module:OnInitialize()
   self.db = ReAction.db:RegisterNamespace( moduleID
     {
@@ -24,7 +24,13 @@
     }
   )
 
-  end
+  -- register some common events
+  ReAction.RegisterCallback(self, "OnCreateBar")
+  ReAction.RegisterCallback(self, "OnDestroyBar")
+  ReAction.RegisterCallback(self, "OnRefreshBar")
+  ReAction.RegisterCallback(self, "OnEraseBar")
+  ReAction.RegisterCallback(self, "OnRenameBar")
+  ReAction.RegisterCallback(self, "OnConfigModeChanged")
 end
 
 function module:OnEnable()
@@ -35,40 +41,33 @@
 
 end
 
-
----- ReAction module API ----
-
 -- apply module features and settings to a bar object (see Bar.lua for Bar API)
-function module:ApplyToBar(bar)
+function module:OnCreateBar(event, bar, name)
 
 end
 
 -- remove module features and settings from a bar object
-function module:RemoveFromBar(bar)
+function module:OnDestroyBar(event, bar, name)
 
 end
 
 -- refresh module features and settings on a bar object
-function module:RefreshBar(bar)
+function module:OnRefreshBar(event, bar, name)
 
 end
 
--- notification of config mode (true/false) on the list of bars
-function module:ApplyConfigMode(mode,listOfBars)
+-- erase any local configuration entries for the supplied bar name
+function module:OnEraseBar(event, bar, name)
 
 end
 
--- return a name-modifier (suffix) for the bar name display. This can reflect a dynamic state.
-function module:GetBarNameModifier(bar)
-  return nil
-end
-
--- erase any local configuration entries for the supplied bar name
-function module:EraseBarConfig(barName)
+-- update any local configuration/option entries with the new bar name index
+function module:OnRenameBar(event, bar, oldName, newName)
 
 end
 
--- update any local configuration entries with the new bar name index
-function module:RenameBarConfig(oldName, newName)
+-- update any local display/options based on config mode (true/false)
+function module:OnConfigModeChanged(event, mode)
 
 end
+