Last active
December 19, 2015 08:59
-
-
Save jwilling/5929321 to your computer and use it in GitHub Desktop.
Handling errors when using toProperty:onObject:.
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
RAC(self.someOrderedSet) = [[[[[[RACAble(self.searchField.text) | |
filter:^BOOL(NSString *text) { | |
return (text.length > 0); | |
}] | |
map:^id(NSString *text) { | |
return [Something searchForAutocomplete:text]; // this signal can send errors | |
}] | |
switchToLatest] | |
catchTo:[RACSignal return:[NSArray array]]] | |
map:^id(NSArray *objects) { | |
NSMutableOrderedSet *orderedSet = [NSMutableOrderedSet orderedSet]; | |
[orderedSet addObjectsFromArray:objects]; | |
return orderedSet; | |
}] | |
retry]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's much more likely you want to catch errors directly from
+searchForAutocomplete:
instead of on the switched signal. That way you don't need to worry about that signal ending with an error: