A lightweight Swift library providing one-line throttle, debounce, and delay functions with built-in thread safety via Swift's actor model.
Throttler is a Swift library that provides simple, one-line functions for throttle, debounce, and delay operations in Apple platform applications. It solves the problem of managing event-driven code execution rates—such as limiting API calls or handling user input—without the overhead of reactive programming frameworks. By leveraging Swift's actor model, it ensures thread safety automatically, allowing developers to focus on logic rather than concurrency concerns.
iOS, macOS, watchOS, and tvOS developers who need to implement rate-limiting or delayed execution in their apps, especially those working with SwiftUI or UIKit and seeking a lightweight alternative to RxSwift or Combine.
Developers choose Throttler for its minimal API that reduces boilerplate, built-in thread safety that eliminates data race risks, and the ability to add advanced throttle/debounce logic without adopting a reactive programming paradigm. It offers a straightforward, performant solution tailored for Swift's modern concurrency model.
One Line to throttle, debounce and delay: Say Goodbye to Reactive Programming such as RxSwift and Combine.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements throttle, debounce, and delay with just a single function call, drastically reducing boilerplate compared to RxSwift or Combine, as shown in the basic usage examples.
Leverages Swift's actor model to automatically prevent data races, ensuring safe access to shared mutable state within closures without manual synchronization, demonstrated in the thread-safe test.
Offers flexible options like 'ensureLast' for throttle and 'runFirst' for debounce, providing more control than basic implementations with minimal code.
Eliminates the need to adopt reactive programming paradigms, making it ideal for projects that only require rate-limiting operations without the overhead of full frameworks.
Requires iOS 16.0+, macOS 13.0+, watchOS 9.0+, or tvOS 16.0+, which excludes support for older devices and legacy applications, as noted in the V2.0.0 update.
Limited to throttle, debounce, and delay functions, lacking other common reactive operators or utilities found in more comprehensive libraries like Combine.
The README strongly recommends using custom identifiers for proper control, which can add complexity and boilerplate in larger or more dynamic codebases.