DORateLimit
DORateLimit 允许您通过对函数调用进行节流和防抖来实施速率限制。关于节流和防抖之间区别的详细说明,可以在这里找到 这里。
用法
RateLimit.throttle("throttleFunctionKey", threshold: 1.0) {
print("triggering throttled closure")
}
RateLimit.debounce("debounceFunctionKey", threshold: 1.0) {
print("triggering debounced closure")
}
安装
速率限制通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod "DORateLimit"
许可证
速率限制在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。