Swiftpack.co - moridaffy/MSDebouncer as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
moridaffy/MSDebouncer
Simple debouncer to use in your iOS apps
.package(url: "https://github.com/moridaffy/MSDebouncer.git", from: "1.0.0")

MSDebouncer

Simple debouncer to use in your iOS apps

Demo

Demo video

How to install?

Manually

  • Just copy the file Debouncer.swift into your project

Swift Package Manager

  • Enter following URL as package repository URL: https://github.com/moridaffy/msdebouncer/
  • Use main branch

Usage

Here's how you can use MSDebouncer in your app:

import MSDebouncer

class ViewController: UIViewController {

  ...

  private var debouncer: Debouncer<String>?

  private func setupDebouncer() {
    self.debouncer = Debouncer(outputType: String.self, debounceTime: 1.0, callback: { value in
      APIManager.shared.searchForItems(query: value)
    })
  }

  private func textFieldUpdated(with text: String) {
    debouncer?.setValue(text)
  }
}

This snippet shows basic implementation of Debouncer when trying to implement live search in your app. It allows you to skip sending network requests to your API after each letter typed while still giving impression of instant search.

GitHub

link
Stars: 0
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics