I have implemented function to download my object ELRun
from the server. My code snippet:
- (void)_requestUserReservation {
[[[networkManager requestRun] subscribeNext:^(ELRun *run) {
[self _setupRun:run];
} error:^(NSError *error) {
//FIXME: renew reservation request here?
NSLog(@"Couldn't receive user reservation");
}];
}
Sometimes I receive an error - then I would like to retry download 2 more times. How should I achieve that using Reactive Cocoa?
I found similar question here, but I have additional next:
event that I have to handle. I tried the code below but it doesn't work:
static int retries = 0;
RACSignal *apiCall = [RACSignal defer:^{
return [self _dynamicClient] requestRun];
}];
return [[apiCall
catch:^(NSError *error) {
retries++;
if (retries < 2)
return apiCall;
else
return [RACSignal empty];
replay];
Any help or suggeestions will be appreciated!