ReactiveObjC Objective-C 的函数响应式编程框架开源项目

我要开发同款
匿名用户2017年02月07日
50阅读
开发技术Object-c
所属分类Objective-C、网络工具包、程序开发
授权协议MIT

作品详情

ReactiveObjC(前身是ReactiveCocoa或者RAC)是一个Objective-C框架,实现了函数响应式编程模式。

最简单的例子:

// When self.username changes, logs the new name to the console.//// RACObserve(self, username) creates a new RACSignal that sends the current// value of self.username, then the new value whenever it changes.// -subscribeNext: will execute the block whenever the signal sends a value.[RACObserve(self, username) subscribeNext:^(NSString *newName) {    NSLog(@"%@", newName);}];

K/V通知

// Only logs names that starts with "j".//// -filter returns a new RACSignal that only sends a new value when its block// returns YES.[[RACObserve(self, username)    filter:^(NSString *newName) {        return [newName hasPrefix:@"j"];    }]    subscribeNext:^(NSString *newName) {        NSLog(@"%@", newName);    }];
查看全文
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论