Latest0.1.1
Homepagehttps://github.com/xremix/SwiftDebouncer
LicenseMIT
Platformsios 8.0
Authors

A simple Swift Library for a Debouncer class to delay function calls

Badge w/ Version
Language
iOS
GitHub license

Description

A Swift Library for a debounce function, similar to the JavaScript debounce.
The Debouncer will delay a function call, and every time it’s getting called it will delay the preceding call until the delay time is over.

Getting started

Usage is as simple as the following code:

let d = Debouncer(delay: 10)
d.callback = {
// your code here
}

d.call()

You can pass a parameter delay (in ms of type TimerInterval) and optional an callback function.

Make sure to check out the Unit Tests for further code samples.

Properties

  • callback Callback that is getting called when the timer fires
  • delay Delay Time in ms
  • fireDate Next Date when the Debouncer will fire

Functions

  • call Call debouncer to start the callback after the delayed time. Multiple calls will ignore the older calls and overwrite the firing time

Installation

CocoaPods

You can install the library to your project by using CocoaPods. Add the following code to your Podfile:

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
pod 'SwiftDebouncer'
end

Git Submodule

You can add the project as a git submodule. Simply drag the SwiftGS1Barcode.xcodeproj file into your Xcode project.
Don’t forget to add the framework in your application target

Manually

Just copy and paste the Debouncer.swift file into your project.

Analytics

About this

  • This was developed to not copy over and over the same classes due different projects
  • Test coverage should be pretty good – was developed using TDD
  • Oriented on this article on how to deploy this on CocoaPods
  • Contributors are very welcome

Latest podspec

{
    "name": "SwiftDebouncer",
    "version": "0.1.1",
    "summary": "Swift Debouncer Library to delay function calls",
    "description": "Swift Debouncer Library to delay function calls and not have them called multiple times at once",
    "homepage": "https://github.com/xremix/SwiftDebouncer",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Toni Hoffmann": "[email protected]"
    },
    "source": {
        "git": "https://github.com/xremix/SwiftDebouncer.git",
        "tag": "0.1.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "SwiftDebouncer/*.swift",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This