Created
April 9, 2014 19:35
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was looking for just that! Thanks 👍