timer.performWithDelay with listener

Could someone please explain why/when you would want to use a table listener based timer as opposed to a function based one…

http://developer.anscamobile.com/content/timer-library [import]uid: 9371 topic_id: 4014 reply_id: 304014[/import]

I guess it’s a matter of convenience. A table is often “an object” in Lua, that is, it contains data and functions pertaining the object itself - and can be as “big” as a final user wants.
Thus tables are generally “heavier” than simple functions. It’s a good idea then to provide such a flexible choice to programmers whether to use full-fat tables or simple functions for easy, light tasks.

Lastly, but equally important, there’s engine programming consistency. Since the whole events/listeneres system provides a choice for tables/functions, when you implement *any* completion listener elsewhere within the engine (i.e. in the class “timer” for instance), it will be based on the “general purpose” listeners system… giving you the same “choice” everywhere. This makes the Corona engine “consistant”. [import]uid: 5750 topic_id: 4014 reply_id: 12347[/import]

IMHO, I would say its down to ease of coding. If a table has a ‘timer’ function the timer will call that function for that table object, not a function shared by the whole program. This means the context is object sensitive, which means the data available to the function is more appropriate to the execution. Its really just Object Oriented coding, rather than functional coding styles. [import]uid: 8271 topic_id: 4014 reply_id: 12433[/import]