Swiftpack.co - moridaffy/MSDebouncer as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by moridaffy.
moridaffy/MSDebouncer 1.0.0
Simple debouncer to use in your iOS apps
⭐️ 0
🕓 2 years ago
.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 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

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