Reputation: 1641
I have a simple subscribeNext: error: chain like:
[[self.viewModel signal] subscribeNext:^(id x) {
NSLog(@"success!");
} error:^(NSError *error) {
NSLog(@"error");
}];
When I receive an error, I successfully print error
, but it seems like the chain is never called again, even if the signal is sent from the view model again after the error. I can't seem to figure out how to use -retry
or -repeat
to resubscribe after the error fires. Any help? Thanks!
Upvotes: 1
Views: 769
Reputation: 11
If you put the -catch:
inside the -flattenMap:
, then the outer signal won't error.
https://github.com/ReactiveCocoa/ReactiveCocoa/issues/1218
Upvotes: 1
Reputation: 1641
Okay! I figured out the answer: You need to catch
the error with a catch block, return a RACSignal with the error, then retry
, then subscribeNext
to the success callback. Like:
[[[[self.viewModel signal] catch:^RACSignal *(NSError *error) {
// Handle the error here
return [RACSignal error:error];
}] retry] subscribeNext:^(id x) {
// Do your success stuff
}];
Upvotes: 3
Reputation: 7287
You need -[RACSignal retry]
:
[[[self.viewModel signal] retry] subscribeNext:^(id x) {
NSLog(@"success!");
} error:^(NSError *error) {
NSLog(@"error");
}];
Upvotes: 0