Commit f633f053 by Dima Bart

Update checkout operation to use atomic property to track running task.

parent 7cfc5336
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
@property (strong, nonatomic, readonly) id<BUYPaymentToken> token; @property (strong, nonatomic, readonly) id<BUYPaymentToken> token;
@property (strong, nonatomic, readonly) BUYCheckoutOperationCompletion completion; @property (strong, nonatomic, readonly) BUYCheckoutOperationCompletion completion;
@property (strong, nonatomic) BUYRequestOperation *currentOperation; @property (strong, atomic) BUYRequestOperation *currentOperation;
@end @end
...@@ -120,10 +120,8 @@ ...@@ -120,10 +120,8 @@
} }
}]; }];
// Update current operation weakSelf.currentOperation = getOperation;
[weakSelf locked:^{
weakSelf.currentOperation = getOperation;
}];
[weakSelf.client startOperation:getOperation]; [weakSelf.client startOperation:getOperation];
}]; }];
...@@ -131,29 +129,21 @@ ...@@ -131,29 +129,21 @@
return response.statusCode == BUYStatusProcessing; return response.statusCode == BUYStatusProcessing;
}; };
// Update current operation weakSelf.currentOperation = pollOperation;
[weakSelf locked:^{
weakSelf.currentOperation = pollOperation;
}];
[weakSelf.client startOperation:pollOperation]; [weakSelf.client startOperation:pollOperation];
}]; }];
// Update current operation // Update current operation
[self locked:^{ self.currentOperation = beginOperation;
self.currentOperation = beginOperation;
}];
[self.client startOperation:beginOperation]; [self.client startOperation:beginOperation];
} }
- (void)cancelExecution - (void)cancelExecution
{ {
[super cancelExecution]; [super cancelExecution];
[self.currentOperation cancel];
__block BUYRequestOperation *currentOperation = nil;
[self locked:^{
currentOperation = self.currentOperation;
}];
[currentOperation cancel];
} }
@end @end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment