Skip to content
Browse files

fixed a "removeEventListener" bug if you don't pass in a listener (wh…

…en it defaults to "self")
  • Loading branch information...
1 parent 6e1f0bc commit 62bb0a6b829a420fad039f3c69426287a1b14270 @johnlindquist committed Aug 15, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 luna/Luna.lua
View
5 luna/Luna.lua
@@ -18,6 +18,8 @@ local function createMessenger()
end
messenger.hasEventListener = function(self, messageName, listener)
+ listener = listener or self
+
for i in ipairs(receivers[messageName]) do
if receivers[messageName][i] == listener then
return true, i
@@ -29,7 +31,7 @@ local function createMessenger()
messenger.addEventListener = function(self, messageName, listener)
print("addEventListener: ", messageName, listener)
- if listener == nil then listener = self end
+ listener = listener or self
receivers[messageName] = receivers[messageName] or {}
local bool, i = self:hasEventListener(messageName, listener)
if bool then
@@ -41,6 +43,7 @@ local function createMessenger()
messenger.removeEventListener = function(self, messageName, listener)
-- print("\nstopReceive: ", messageName, listener)
+ listener = listener or self
local bool, i = self:hasEventListener(messageName, listener)
if bool then table.remove(receivers[messageName], i) end
end

0 comments on commit 62bb0a6

Please sign in to comment.
Something went wrong with that request. Please try again.