Throttling wraps a block of code with throttling logic, guaranteeing that an action will never be called more than once each specified interval.
To run the example project, clone the repo, and run pod install
from the Example directory first.
var throttler : Throttler?
var counter = 0
override func viewDidLoad() {
super.viewDidLoad()
self.throttler = Throttler(seconds: 5)
}
@IBAction func buttonDidTapped(_ sender: UIButton) {
self.counter += 1
self.throttler?.throttle(block: {
print(self.counter)
})
}
RBThrottler is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'RBThrottler'
rezabina86, tavakolibina@gmail.com
RBThrottler is available under the MIT license. See the LICENSE file for more info.