It would be nice to have some oop aka object-table support for the Listeners.
If I need to perform more than one delay within an object (=table) I have to use additional if/thens and state variables.
Example:
local myObj = {}
function myObj:timer( event )
if (self.state ==1) then
print (“timer1 end”);
self:run2();
elsif (self.state ==2) then
print (“timer2 end”);
elsif – a lot if if/thens if a lot of timers used!!
…
end;
function myObj:run1()
self.state = 1;
timer.performWithDelay(1000, self);
end;
function myObj:run2()
self.state = 2;
timer.performWithDealy(1000, self);
end;
myObj:run1();
Suggestion:
Would be nicer by specifying a table (=obj, =self) and a corresponding table function.
local myObj = {}
function myObj:end1( event )
print (“timer1 end”);
self:run2();
end;
function myObj:end2( event )
print (“timer2 end”);
end;
function myObj:run1()
timer.performWithDelay(1000, self, self.end1);
end;
function myObj:run2()
timer.performWithDelay(1000, self, self.end2);
end;
That means if second param is a table (=self) and third is a function it indicates an oop function call - here we need both, the function and the object in order to pass it as a param, something like
self.endFunc(self, event);
[import]uid: 3642 topic_id: 866 reply_id: 300866[/import]