Skip to content
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

Timer's require strong references #21

Closed
anthonycastelli opened this issue Apr 13, 2018 · 1 comment
Closed

Timer's require strong references #21

anthonycastelli opened this issue Apr 13, 2018 · 1 comment
Assignees
Labels
invalid This doesn't seem right question Further information is requested

Comments

@anthonycastelli
Copy link

No matter what function I use, every times requires a strong reference in order to fire.

Everything instantly deallocates itself if I dont have a strong reference. I'm creating multiple timers and dont want to have to declare a dozen variables to store all of these, thats just not practical.

Looking at the tests, I should be able to do this, however, the same thing appears to happen here.

let timer = Repeater(interval: .seconds(1), mode: .infinite) { timer in
    print("Timer")
}
timer.start()

Did I miss something in the readme about this requiring a strong reference of itself to continuously fire, or is this a bug? Been wracking my head out for about 2 hours trying to figure out what the hell was going on.

Thanks

@malcommac
Copy link
Owner

This is a memory management question; obviously you need to keep the timer alive as any other object, so strong reference is part of the game.
I've also added this stuff into the doc, even if its a general question more than a specific timer-related question.

@malcommac malcommac self-assigned this Apr 28, 2018
@malcommac malcommac added invalid This doesn't seem right question Further information is requested labels Apr 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants