Awesome Open Source
Awesome Open Source

GCDThrottle

Language License

A lightweight GCD wrapper to throttling frequent method calling

🇨🇳中文介绍

Purpose

Throttling frequent method calling with a threshold time interval, for example text searching.

Usage

#import "ViewController.h"
#import "GCDThrottle.h"

@implementation ViewController

- (IBAction)textFieldValueChanged:(UITextField *)sender {
    
    dispatch_throttle(0.3, ^{
        NSLog(@"search: %@", sender.text);
    });
    
    dispatch_throttle_on_queue(0.3, THROTTLE_GLOBAL_QUEUE, ^{
        NSLog(@"search: %@", sender.text);
    });
    
    [GCDThrottle throttle:0.3 block:^{
        NSLog(@"search: %@", sender.text);
    }];
    
    [GCDThrottle throttle:0.3 queue:THROTTLE_GLOBAL_QUEUE block:^{
        NSLog(@"search: %@", sender.text);
    }];
}

@end

That's all

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Objective C (57,107
Threshold (3,496
Gcd (643
Throttling (609