Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

ReactiveCocoa: How to initialize a RACScheduler with a serially executing GCD queue.

View RACSerialScheduler.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
@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
Owner

Usage:

...
    @weakify(self)
    return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
        @strongify(self)
        return [self.serialScheduler schedule:^{
            // do something
        }];
    }]
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.