- It is documented. They are called table listeners:
https://docs.coronalabs.com/guide/events/detectEvents/index.html#function-and-table-listeners
2. What I’m doing is clearing the variable that points to the function as a bookkeeping thing for my code.
Elsewhere I check to be sure obj.enterFrame is present before removing the listener.
If I don’t do this, it will crash.
Ex: This would crash:
function obj.enterFrame(self) end Runtime:addEventListener( "enterFrame", obj ) local function cancelIt() Runtime:removeEventListener( "enterFrame", obj ) obj.enterFrame = nil end cancelIt() ... later cancelIt()-- CRASH
This logic prevents the issue:
function obj.enterFrame(self) end Runtime:addEventListener( "enterFrame", obj ) local function cancelIt() if( not obj.enterFrame ) then return end Runtime:removeEventListener( "enterFrame", obj ) obj.enterFrame = nil end cancelIt() ... later cancelIt()
