///////////////////各种机制转信号///////////////////////////////

1.UI事件

[self.logInButton rac_signalForControlEvents:UIControlEventTouchUpInside]

2.Delegate回调

[self rac_signalForSelector:@selector(flickrAPIRequest:didCompleteWithResponse:) fromProtocol:@protocol(OFFlickrAPIRequestDelegate)];

3.Notificaiton

[NSNotificationCenter.defaultCenter rac_addObserverForName:UserDidLogOutNotification object:nil]

4.KVO观察

[RACObserve(self, username)]

5.Target-Action

[self rac_signalForSelector:@selector(didChangeValueForKey:)]

////////////////////常用情景//////////////////////////////////

 6.AlertView

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"" message:@"Alert" delegate:nil cancelButtonTitle:@"YES" otherButtonTitles:@"NO", nil];
[[alertView rac_buttonClickedSignal] subscribeNext:^(NSNumber *indexNumber) {
    if ([indexNumber intValue] == 1) {
        NSLog(@"you touched NO");
    } else {
        NSLog(@"you touched YES");
    }
}];
[alertView show];

 7.Gesture

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] init]; 
    tapGesture.numberOfTapsRequired = 2; 
    [[tapGesture rac_gestureSignal] subscribeNext:^(id x) { 
        [self.viewModel.likeCommand execute:nil]; 
    }]; 

 

相关文章:

  • 2022-12-23
  • 2021-07-11
  • 2021-08-06
  • 2021-11-19
  • 2021-11-10
  • 2021-09-29
  • 2021-04-15
  • 2021-11-05
猜你喜欢
  • 2021-08-11
  • 2021-05-16
  • 2021-04-09
  • 2021-08-14
  • 2022-01-10
  • 2022-01-04
  • 2022-12-23
相关资源
相似解决方案