CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

DispatchThrottle 1.0.3

DispatchThrottle 1.0.3

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Nov 2017
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by Gerrel Krishan.



  • By
  • Gerrel Krishan

DispatchThrottle

CI Status
Version
License
Platform

Throttle mechanism for DispatchQueue. Only the last dispatched code-block will be executed when delay has passed.

Installation

DispatchThrottle is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'DispatchThrottle'

For documentation

Run the following terminal command in the root of the project

$ jazzy

Example

  1. Define DispatchThrottle as a variable:
let throttle = DispatchThrottle(time: DispatchTimeInterval.milliseconds(100))
  1. Use throttle in func that should have delayed execution if multiple (unnecessary) invocation can be received in a short time
let throttle = DispatchThrottle(time: DispatchTimeInterval.milliseconds(100))

// ...

internal func save() {
    
    DispatchQueue.global(qos: .background).async(throttle: throttle) {
        // Write file to disk
    }
}

License

DispatchThrottle is available under the MIT license. See the LICENSE file for more info.