Last active
August 29, 2015 13:56
-
-
Save alexmnps/8801996 to your computer and use it in GitHub Desktop.
ReactiveCocoa: How to initialize a RACScheduler with a serially executing GCD queue.
This file contains hidden or 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
| @interface SerialScheduler () | |
| @property (nonatomic, strong) RACScheduler *serialScheduler; | |
| @end | |
| @implementation SerialScheduler | |
| /** | |
| * This scheduler executes signals one a 1-by-1 basis. | |
| * Use it with ReactiveCocoa when you want to handle signal execution serially. | |
| */ | |
| - (RACScheduler *)serialScheduler | |
| { | |
| if(!_serialScheduler){ | |
| _serialScheduler = [[RACTargetQueueScheduler alloc] initWithName:@"QueueName" | |
| targetQueue:dispatch_queue_create("QueueName", DISPATCH_QUEUE_SERIAL)]; | |
| } | |
| return _serialScheduler; | |
| } | |
| @end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
... @weakify(self) return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { @strongify(self) return [self.serialScheduler schedule:^{ // do something }]; }] ...