Giter Club home page Giter Club logo

swiftdebouncer's Introduction

SwiftDebouncer

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 SwiftDebouncer.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

swiftdebouncer's People

Contributors

xremix avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

swiftdebouncer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.