[[[DTObservable alloc] init:^(DTSubscriber *subscriber) {
// Setup some data
NSDictionary *value = @{@"4": @20};
// Lets pretend something cpu intensive happens here
[NSThread sleepForTimeInterval:1.f];
// Notify the subscriber
[subscriber next:value];
[subscriber complete];
}] subscribe:[[DTSubscriber alloc] init:^(NSDictionary *value) {
// Confirm the result
BOOL fourTwenty = [value[@"4"] intValue] == 20;
// Success!
NSLog(@"Does 4 == 20? %@", fourTwenty ? @"YES" : @"NO");
} onError:^(NSError *error) {
NSLog(@"%@", error);
}]];
DTObservable 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:
pod 'DTObservable', '0.4.5'
DTHENG, [email protected]
DTObservable 在 MIT 许可下可用。更多信息请参阅 LICENSE 文件。