当前框架写法
self.Dispatcher = NotificationCenter() 初始化 事件中心
2 添加 事件 self.Btn_Take:AddListener(function()
self.Dispatcher:Trigger("OnClickTake")
end)
3事件触发 self.Dispatcher:Listen("OnClickTake", function(scope)
scope.SelectCom:TakeReward()
end, self)
---优先级 Awake OnEnable
OnDisable --针对于事件注销
local function OnDisable(self)
base.OnDisable(self)
self.Btn_Back:RemoveAllListeners()
self.Btn_Take:RemoveAllListeners()
self.Btn_DeleteAll:RemoveAllListeners()
self.Btn_TakeAll:RemoveAllListeners()
end
--销毁
local function OnDestroy(self)
base.OnDestroy(self)
end
关闭UI
local function Close(param)
Log("------OnClick Close Btn------param: " .. type(param))
--GFramework.LiteUI.GoBackToMain()
GFramework.LiteUI.GoBack(param)
end
---消息处理方式、
local Register = NetRegister()
local function AddRegister()
Register:AddRequest("syncmails", syncmails)
Register:AddRequest("addnewmails", addnewmails)
Register:AddRequest("removemails", removemails)
Register:AddRequest("updatemailstatus", updatemailstatus)
Register:AddRequest("colletmail", colletmail)
Register:AddRequest("pullmails", pullmails)
Register:AddRequest("delmails", delmails)
Net.Register(Register:GetProtos(), Register) --参数为
end