zoukankan      html  css  js  c++  java
  • RAC转换传统的通信

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

    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]; 
        }]; 
  • 相关阅读:
    桥接模式
    单例模式
    迭代器模式
    组合模式
    备忘录模式
    适配器模式
    状态模式
    观察者模式
    golang 字符串统计
    go bytes缓冲区使用介绍 -转自https://www.cnblogs.com/--xiaoyao--/p/5122138.html
  • 原文地址:https://www.cnblogs.com/guoxiaoqian/p/4683350.html
Copyright © 2011-2022 走看看