layervault / LVDebounce

An Objective-C library for debouncing NSTimers
MIT License
14 stars 6 forks source link

adds runloop selection #3

Closed theladyjaye closed 8 years ago

theladyjaye commented 10 years ago

When using this in my NSDocument based application, I have the following defined for my NSDocument subclass:

+ (BOOL)canConcurrentlyReadDocumentsOfType:(NSString *)typeName

This returns YES which is great for my needs, but while the document is loading I need to schedule some debouncing operations, also good, except the current implementation of LVDebounce always assumes the current RunLoop. Once the background loading of the NSDocument completes, the background thread performing the load will finish and the debounce action will never fire.

Allowing the RunLoop to be specifically defined solves this problem. In my loading setup, I just set the runloop in my call to LVDebounce to be [NSRunLoop mainRunLoop] and everything works as expected.

Again, if the runloop is not specified, the currentRunLoop is assumed.

codecaffeine commented 10 years ago

Hi @aventurella, sorry to reply so late.

This PR is fine, but would you mind just adding:

+ (void)fireAfter:(NSTimeInterval)seconds target:(id)target selector:(SEL)aSelector userInfo:(id)userInfo runLoop:(NSRunLoop *)runLoop;

rather than replacing the current method, and have the current method call this method with runLoop:nil? That way I can just make this a 0.1.0 change since it won't break any API. Thanks