Skip to content

baekteun/EventLimiter

Repository files navigation

EventLimiter

Simple classes for efficiently handling events.

Document


Contents

Requirements

  • iOS 13.0+
  • tvOS 13.0+
  • macOS 10.15+
  • watchOS 6.0+
  • Swift 5.0+

Overview

Simple classes for efficiently handling events. You can use the Debouncer and Throttler to handle events.

Installation

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. Itโ€™s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

To integrate EventLimiter into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift:

dependencies: [
    .package(url: "https://github.com/baekteun/EventLimiter.git", .upToNextMajor(from: "1.0.0"))
]

Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate EventLimiter into your project manually.


Usage

QuickStart

let debouncer = Debouncer(for: 0.3)
debouncer {
    await self.search(keyword: keyword)
}
debouncer.cancel()
let throttler = Throttler(for: 1, latest: false)
throttler {
    await self.reachedBottom()
}
throttler.cancel()