Created
June 19, 2015 09:01
-
-
Save hsavit1/310c35777b34037a4df4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
RACImmediateScheduler | |
Private scheduler used in ReactiveCocoa internally and and supports only synchronous scheduling. It simply execute the block right away. Delayed scheduling works by blocking current thread with -[NSThread sleepUntilDate:]. Obviously, there's no way to control cancellation of such scheduling, so disposables retuned by this scheduler will do nothing (in fact, scheduling methods of this scheduler return nil). | |
RACQueueScheduler | |
This scheduler uses GCD queues for scheduling blocks. It's functionality is pretty straightforward if you know what GCD does. It's actually a very thin layer over dispatching blocks in GCD queues. | |
RACSubscriptionScheduler | |
Another private scheduler used by framework internally. It forwards scheduling to current thread's scheduler (scheduler can be associated with the thread) if it exists or to default background queue scheduler. | |
*/ | |
///methods look like this | |
- (RACDisposable *)schedule:(void (^)(void))block; | |
- (RACDisposable *)after:(NSDate *)date schedule:(void (^)(void))block; | |
- (RACDisposable *)afterDelay:(NSTimeInterval)delay schedule:(void (^)(void))block; | |
- (RACDisposable *)after:(NSDate *)date repeatingEvery:(NSTimeInterval)interval withLeeway:(NSTimeInterval)leeway schedule:(void (^)(void))block; | |
//implementation | |
RACDisposable *disposable = [[RACScheduler mainThreadScheduler] afterDelay:5.0 schedule:^{ | |
//do something | |
}]; | |
//if you changed your mind | |
[disposable dispose]; // block scheduling cancelled, it won't be executed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment