You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
930 B
31 lines
930 B
// |
|
// NSNotificationCenter+RACSupport.m |
|
// ReactiveObjC |
|
// |
|
// Created by Josh Abernathy on 5/10/12. |
|
// Copyright (c) 2012 GitHub. All rights reserved. |
|
// |
|
|
|
#import "NSNotificationCenter+RACSupport.h" |
|
#import <ReactiveObjC/RACEXTScope.h> |
|
#import "RACSignal.h" |
|
#import "RACSubscriber.h" |
|
#import "RACDisposable.h" |
|
|
|
@implementation NSNotificationCenter (RACSupport) |
|
|
|
- (RACSignal *)rac_addObserverForName:(NSString *)notificationName object:(id)object { |
|
@unsafeify(object); |
|
return [[RACSignal createSignal:^(id<RACSubscriber> subscriber) { |
|
@strongify(object); |
|
id observer = [self addObserverForName:notificationName object:object queue:nil usingBlock:^(NSNotification *note) { |
|
[subscriber sendNext:note]; |
|
}]; |
|
|
|
return [RACDisposable disposableWithBlock:^{ |
|
[self removeObserver:observer]; |
|
}]; |
|
}] setNameWithFormat:@"-rac_addObserverForName: %@ object: <%@: %p>", notificationName, [object class], object]; |
|
} |
|
|
|
@end
|
|
|