-
-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(timer): restart can prevent executing onEnd function #667
base: master
Are you sure you want to change the base?
Conversation
Didn't notice we can disable/enable it thru :forceEnd
Seems like a having a definitive one way or the other isn't ideal. An optional parameter that lets users toggle the trigger of the onEnd function. With the default being false to prevent a breaking change. |
agree, should be good! |
for my PR overextended/ox_lib#667 Signed-off-by: Frowmza <[email protected]>
if type(onEnd) == 'function' then | ||
self.private.onEnd = onEnd | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think dynamically adding an onEnd function during a reset makes a lot of sense. What would this use case actually be?
@thelindat what are your thoughts on allowing an onEnd function to be added during a reset? Personally it feels like a really confusing user experience / flow.
function timer:restart(async) | ||
self:forceEnd(false) | ||
function timer:restart(async, onEnd) | ||
self:forceEnd(not not onEnd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this double not
flip is to handle the function case, but I think there is a better way to handle this if we do end up wanting the onEnd to accept a function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah just to pass it as boolean
and not function
. But let see what linden got!
I have a different idea to resolve this problem. |
If we want to restart a timer, previous state would disable the variable that triggers the OnEnd function by default.