Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

Better timers #4

Open
LuaFan2 opened this issue Aug 17, 2020 · 1 comment
Open

Better timers #4

LuaFan2 opened this issue Aug 17, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@LuaFan2
Copy link

LuaFan2 commented Aug 17, 2020

The timers that are in use now are just their likeness.
IMHO would be nice to make them like this:

-- Creates a simple timer that runs the given function after a specified delay.
function timer.simple(delay, function) end

-- other possible function name - timer.create
-- Creates a new timer that will repeat its function given amount of times.
function timer.repeating(delay, repititions, function)
creates and returnes TimerObject
end

function TimerObject:Pause() end
function TimerObject:Resume() end
function TimerObject:Restart() end

-- Returns amount of repetitions/executions left before the timer destroys itself.
function TimerObject():RespLeft() end

function TimerObject:Adjust(delay, repititions, function) end
function TimerObject:Destroy() end

I think everyone agrees that such timers will save a lot of effort.

@benank benank added the enhancement New feature or request label Aug 17, 2020
@benank
Copy link
Member

benank commented Aug 17, 2020

Good idea, but I don't think it's fit for the Timer class. The Timer class is specifically for timing things - the changes suggested here do not time anything, but rather provide utility for callbacks after a specific amount of time, either once or on an interval. I think it'd be better to have another class for these types of operations, named Callback or similar.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants