CocoaPods trunk is moving to be read-only. Read more on the blog, there are 11 months to go.
| TestsTested | ✓ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Dec 2014 |
Maintained by Matthew Holden.
This is an Objective-C implementation of a method debouncer. You can read more about deboucing here.
You have the option of:
NSTimeInterval delayLength = 1.0;
NSMutableArray *myArray = [NSMutableArray array];
for (int i = 0; i < 3; i++) {
[myArray addObject:@(i)];
}
// One second (delayLength) later, myArray will hold a single element, the number 3.
// The `addObject:` message was only sent to myArray a single time
// Make three mutable arrays
NSArray *arrayInstances = @[[NSMutableArray new], [NSMutableArray new], [NSMutableArray new]];
NSTimeInterval delay = 1.0;
for (int i = 0; i < 3; i++) {
// Debounce any message sent from this specific call site, regardless
// of the receiver or message name
[MFHDebouncedCallSite(arrayInstances[i], delay) addObject:@(i)];
}
// .... one second later,
// Only the last object that was messaged will have received 'addObject:'
[arrayInstances[0] count] == 0; //true
[arrayInstances[1] count] == 0; //true
[arrayInstances[2] count] == 1; //true
[arrayInstances[2] objectAtIndex:0] == @3; //trueMatthew Holden @MFHolden
MFHMessageDebouncer is available under the MIT license. See the LICENSE file for more info.