Skip to content

A lightweight Objective-C function throttle and debounce library.

License

Notifications You must be signed in to change notification settings

wangwanjie/WJFunctionThrottle

Repository files navigation

WJFunctionThrottle

A lightweight Objective-C function throttle and debounce library.

CI Status Version License Platform

Effect

Effect

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Use

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];
                                     }];

Requirements

iOS 8 or above.

Installation

WJFunctionThrottle is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'WJFunctionThrottle'

Author

wangwanjie, wangwanjie1993@gmail.com

License

WJFunctionThrottle is available under the MIT license. See the LICENSE file for more info.

About

A lightweight Objective-C function throttle and debounce library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published