Anton Chuiko
Anton Chuiko

Reputation: 245

Retrying RACObserve until success

I have RACObserve block and I want to retry calling until it is successfully returns. So it won't show the Error message, but it will retry to fetch. Thanks for help!

    [[[[RACObserve(self, currentLocation)
        ignore:nil]

       flattenMap:^(CLLocation *newLocation) {
           return [RACSignal merge:@[
                                     [self updateCurrentConditions],
                                     [self updateDailyForecast],
                                     [self updateHourlyForecast]
                                     ]];

       }] deliverOn:RACScheduler.mainThreadScheduler]

     subscribeError:^(NSError *error) {
         [TSMessage showNotificationWithTitle:@"Error"
                                     subtitle:@"There was a problem fetching the latest weather."
                                         type:TSMessageNotificationTypeError];
     }];

Upvotes: 1

Views: 83

Answers (1)

Charles Maria
Charles Maria

Reputation: 2195

Use the method retry at the last point in the call chain before subscription.

Upvotes: 1

Related Questions