DispatchTimer is a GCD-powered timer with a similar API to Timer (née NSTimer). DispatchTimer‘s big advantage over Timer is it doesn’t need a RunLoop to fire, which means you can use DispatchTimer on background threads without any problems. The disadvantage of DispatchTimer is you need to retain a reference to it or it won’t fire.
Installation
To use DispatchTimer with the Swift Package Manager, add a dependency to your Package.swift file:
DispatchTimer
DispatchTimeris a GCD-powered timer with a similar API toTimer(néeNSTimer).DispatchTimer‘s big advantage overTimeris it doesn’t need aRunLoopto fire, which means you can useDispatchTimeron background threads without any problems. The disadvantage ofDispatchTimeris you need to retain a reference to it or it won’t fire.Installation
To use
DispatchTimerwith the Swift Package Manager, add a dependency to yourPackage.swiftfile:Usage
License
The license for
DispatchTimeris the standard MIT license. You can find it in theLICENSEfile.