hfossli
hfossli

Reputation: 22992

Create a RACSignal which sends error if RACSignal sends next

With ReactiveCocoa I'm sure there is a better way than doing this?

RACSignal *crashSignal = [cancelSignal tryMap:^id(id value, NSError **errorPtr) {
    *errorPtr = [self createError];
    return nil;
}];

Upvotes: 4

Views: 1163

Answers (1)

joshaber
joshaber

Reputation: 2465

More idiomatic would be:

RACSignal *crashSignal = [cancelSignal flattenMap:^(id value) {
    return [RACSignal error:[self createError]];
}];

Upvotes: 11

Related Questions