The library allows you to create a timer that works either with RunLoop or with GCD.
- Track the time even while the application is in the background. For more, see - TimerRunMode
- Create a timer on a personal queue or on a special Runloop mode. For more, see - TimerType
- The code is covered by tests 🙂
timer = TITimer(type: .runloopTimer(runloop: .current, mode: .default), mode: .activeAndBackground)
timer.eventHandler = {
// handle elapsed time
}
timer.start()
timer.invalidate()
timer = TITimer(type: .dispatchSourceTimer(queue: .main), mode: .activeAndBackground)
timer.eventHandler = {
// handle elapsed time
}
timer.start()
timer.invalidate()