Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/comyar/Chronos-Swift
:hourglass: Grand Central Dispatch Utilities
https://github.com/comyar/Chronos-Swift
Last synced: 3 months ago
JSON representation
:hourglass: Grand Central Dispatch Utilities
- Host: GitHub
- URL: https://github.com/comyar/Chronos-Swift
- Owner: comyar
- License: mit
- Created: 2015-03-31T03:40:19.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-28T18:28:23.000Z (almost 7 years ago)
- Last Synced: 2024-05-15T23:47:26.699Z (6 months ago)
- Language: Swift
- Homepage:
- Size: 151 KB
- Stars: 248
- Watchers: 13
- Forks: 28
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - Chronos-Swift - Grand Central Dispatch Utilities. (GCD / Getting Started)
- awesome-swift - Chronos - Grand Central Dispatch Utilities. (Libs / Thread)
- awesome-ios-star - Chronos-Swift - Grand Central Dispatch Utilities. (GCD / Getting Started)
README
![](header.png)
# Overview
[![Build Status](https://travis-ci.org/comyar/Chronos-Swift.svg)](https://travis-ci.org/comyar/Chronos-Swift)
[![Version](http://img.shields.io/cocoapods/v/Chronos-Swift.svg)](http://cocoapods.org/?q=Chronos)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Olympus-Library/Chronos-Swift)
[![Platform](http://img.shields.io/cocoapods/p/Chronos-Swift.svg)]()
[![License](http://img.shields.io/cocoapods/l/Chronos-Swift.svg)](https://github.com/Olympus-Library/Chronos/blob/master/LICENSE)
[![git-brag-stats](https://labs.turbo.run/git-brag?user=comyar&repo=Chronos-Swift)](https://github.com/comyar/Chronos-Swift)Chronos is a collection of useful Grand Central Dispatch utilities. If you have any specific requests or ideas for new utilities, don't hesitate to create a new issue.
## Utilities
* **DispatchTimer** - A repeating timer that fires according to a static interval, e.g. "Fire every 5 seconds".
* **VariableTimer** - A repeating timer that allows you to vary the interval between firings, e.g. "Fire according to the function `interval = 2 * count`."# Usage
### Quick Start
##### CocoaPods
Add the following to your Podfile:
```ruby
pod 'Chronos-Swift'
```
##### CarthageAdd the following to your Cartfile:
```ruby
github "comyarzaheri/Chronos-Swift" "master"
```### Using a Dispatch Timer
```swift
import Chronosvar timer = DispatchTimer(interval: 0.25, closure: {
(timer: RepeatingTimer, count: Int) in
println("Execute repeating task here")
})/** Starting the timer */
timer.start(true) // Fires timer immediately/** Pausing the timer */
timer.pause()/** Permanently canceling the timer */
timer.cancel()```
### Using a Variable Timer
```swift
import Chronosvar variableTimer: VariableTimer = VariableTimer(closure: {
(timer: RepeatingTimer, count: Int) -> Void in
println("Execute repeating task here")
}) {(timer: VariableTimer, count: Int) -> Double in
return Double(2 * count) // Return interval according to function
}/** Starting the timer */
timer.start(true) // Fires timer immediately/** Pausing the timer */
timer.pause()/** Permanently canceling the timer */
timer.cancel()```
# Requirements
* iOS 8.0 or higher
* OS X 10.10 or higher# License
Chronos is available under the [MIT License](LICENSE).
# Contributors
* [@comyar](https://github.com/comyar)
* [@schun93](https://github.com/schun93)
* [@tokorom](https://github.com/tokorom)
* [@ggiampietro](https://github.com/ggiampietro)