A lightweight Objective-C function throttle and debounce library.
To run the example project, clone the repo, and run pod install
from the Example directory first.
if (text && text.length > 0) {
[WJFunctionThrottle throttleWithInterval:0.5
key:@"key"
handler:^{
NSLog(@"text changed, search for keyword:%@", textfield.text);
}];
} else {
[WJFunctionThrottle throttleCancelWithKey:@"key"];
}
[WJFunctionThrottle throttleWithInterval:0.1
type:WJFunctionThrottleTypeInvokeOnceInEachInterval
handler:^{
[self handerScrollViewDidScrollWithThrollteOffset:scrollView.contentOffset];
}];
iOS 8 or above.
WJFunctionThrottle is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'WJFunctionThrottle'
wangwanjie, wangwanjie1993@gmail.com
WJFunctionThrottle is available under the MIT license. See the LICENSE file for more info.