文件名称:Objective-C的函数响应式编程框架ReactiveObjC.zip
文件大小:1.22MB
文件格式:ZIP
更新时间:2022-08-08 00:17:20
开源项目
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); }]; 标签:ReactiveObjC