Skip to content

Instantly share code, notes, and snippets.

@dustin-graham
Created April 9, 2014 19:35
Show Gist options
  • Save dustin-graham/10306356 to your computer and use it in GitHub Desktop.
Save dustin-graham/10306356 to your computer and use it in GitHub Desktop.
Combining to signals created from delegate callbacks where one is a success message and another is a failure. convert the failure into an error signal
RACSignal *connectionSignal = [self rac_signalForSelector:@selector(centralManager:didConnectPeripheral:) fromProtocol:@protocol(CBCentralManagerDelegate)];
RACSignal *connectionFailureSignal = [[self rac_signalForSelector:@selector(centralManager:didFailToConnectPeripheral:error:) fromProtocol:@protocol(CBCentralManagerDelegate)] flattenMap:^RACStream *(RACTuple *tuple) {
return [RACSignal error:tuple.third];
}];
RACSignal *completeConnectionSignal = [[RACSignal merge:@[connectionSignal,connectionFailureSignal]] catch:^RACSignal *(NSError *error) {
//handle the connection failure?
}];
@avi-midtown
Copy link

I was looking for just that! Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment