| // UIControl+RACSignalSupport.m |
| // Created by Josh Abernathy on 4/17/12. |
| // Copyright (c) 2012 GitHub, Inc. All rights reserved. |
| #import "UIControl+RACSignalSupport.h" |
| #import "RACCompoundDisposable.h" |
| #import "RACDisposable.h" |
| #import "RACSignal+Operations.h" |
| #import "RACSubscriber+Private.h" |
| #import "NSObject+RACDeallocating.h" |
| #import "NSObject+RACDescription.h" |
| @implementation UIControl (RACSignalSupport) |
| - (RACSignal *)rac_signalForControlEvents:(UIControlEvents)controlEvents { |
| createSignal:^(id<RACSubscriber> subscriber) { |
| [self addTarget:subscriber action:@selector(sendNext:) forControlEvents:controlEvents]; |
| [self.rac_deallocDisposable addDisposable:[RACDisposable disposableWithBlock:^{ |
| [subscriber sendCompleted]; |
| return [RACDisposable disposableWithBlock:^{ |
| [self removeTarget:subscriber action:@selector(sendNext:) forControlEvents:controlEvents]; |
| setNameWithFormat:@"%@ -rac_signalForControlEvents: %lx", [self rac_description], (unsigned long)controlEvents]; |