也许我误会了concat? 为什么这段代码输出也不是“B” 我得到一个输出“A” 不应该像这样连续工作:
RACSignal *signal = [RACSignal createSignal:^ RACDisposable * (id<RACSubscriber> subscriber) {
[subscriber sendNext:@"A"];
return nil;
}];
signal = [signal concat:[RACSignal createSignal:^ RACDisposable * (id<RACSubscriber> subscriber) {
[subscriber sendNext:@"B"];
return nil;
}] ];
signal= [signal doNext:^(id x){
NSLog(@"doNext %@",x);
}];
signal= [signal flattenMap:^RACStream *(id value) {
NSLog(@"flattenMap %@", value);
return [RACSignal return:value];
}];
signal=[signal doNext:^(id x){
NSLog(@"doNext after flattenMap %@",x);
}];
[signal subscribeNext:^(id x) {
NSLog(@"subscribeNext %@", x);
}];
答案 0 :(得分:1)
你的第一个信号永远不会完成。如果您在致电[subscriber sendCompleted]
后致电[subscriber sendNext:@"A"]
,那么您会发现-concat:
符合预期。