Swiftpack.co - Tunous/DebouncedOnChange as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Tunous.
Tunous/DebouncedOnChange 1.1.0
SwiftUI onChange View extension with debounce time
⭐️ 55
🕓 48 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/Tunous/DebouncedOnChange.git", from: "1.1.0")

DebouncedOnChange

A SwiftUI onChange and task view modifiers with additional debounce time.

Usage

import SwiftUI
import DebouncedOnChange

struct ExampleView: View {
    @State private var text = ""

    var body: some View {
        TextField("Text", text: $text)
            .onChange(of: text, debounceTime: .seconds(2)) { newValue in
                // Action executed each time 2 seconds pass since change of text property
            }
            .task(id: text, debounceTime: .milliseconds(250)) { 
                // Asynchronous action executed each time 250 milliseconds pass since change of text property
            }
    }
}

Installation

Swift Package Manager

Add the following to the dependencies array in your "Package.swift" file:

.package(url: "https://github.com/Tunous/DebouncedOnChange.git", .upToNextMajor(from: "1.1.0"))

Or add https://github.com/Tunous/DebouncedOnChange.git, to the list of Swift packages for any project in Xcode.

GitHub

link
Stars: 55
Last commit: 4 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.1.0
48 weeks ago
  • Debounced version of task(id:priority:_:) modifier
  • Use of Duration type as debounceTime parameter

Full Changelog: https://github.com/Tunous/DebouncedOnChange/compare/1.0.2...1.1.0

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