这非常出色......
@interface Hello : NSObject
@property (nonatomic, strong, readonly) RACSignal *signal;
@end
@interface Hello ()
@property (nonatomic, strong, readwrite) RACSignal *signal;
@end
@implementation Hello
- (instancetype)init
{
self = [super init];
if(self)
{
self.signal = [[[self createSignal] replayLazily];
}
return self;
}
- (RACSignal *)createSignal
{
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
[[Service getInstance] getProducts:^(NSArray *products) {
[subscriber sendNext:products];
[subscriber sendCompleted];
} error:^(NSError *error) {
[subscriber sendError:error];
}];
}];
}
@end
......只要没有错误。
我想这是因为RACMulticastConnection的sourceSignal发送了一个错误。
我想要的行为
答案 0 :(得分:1)
出现错误时重新创建信号
- (RACSignal *)createSignal
{
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
[[Service getInstance] getProducts:^(NSArray *products) {
[subscriber sendNext:products];
[subscriber sendCompleted];
} error:^(NSError *error) {
[subscriber sendError:error];
self.signal = [[[self createSignal] replayLazily];
}];
}];
}