Skip to content

Repository files navigation

DispatchTimer

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:

dependencies:[.package(url:"https://github.com/shareup/dispatch-timer.git", from:"3.0.0"),],

Usage

letoneoff=DispatchTimer(.milliseconds(50), block:{print("fired")})letrepeating=DispatchTimer(.milliseconds(50),repeat:true,
block:{print("fired")})letfireAt=DispatchTimer(
fireAt:DispatchTime.now()+.milliseconds(50),
block:{print("fired")})

License

The license for DispatchTimer is the standard MIT license. You can find it in the LICENSE file.

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages