下载地址:https://github.com/ReactiveCocoa/ReactiveObjC
#import <ReactiveObjC/ReactiveObjC.h>
一、通知
//监听App离开了
__block RACDisposable *notf = [[[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIApplicationWillResignActiveNotification object:nil] takeUntil:[self rac_willDeallocSignal]] subscribeNext:^(NSNotification * _Nullable x) {
//分享结果回调,点击就算分享成功
if (completion) {
completion(@"1",@"");//分享成功
}
[notf dispose];//销毁通知
}];
二、监听对象属性变化(KVO)
[[_progressView rac_valuesForKeyPath:@"progress" observer:self] subscribeNext:^(id _Nullable x) {
weakself.walkProgressView.progressView.progress = [x floatValue];
}];
三、Button点击事件
[[cancelButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
}];