saltedge / saltedge-ios

A handful of classes to help you interact with the Salt Edge API from your iOS app
https://www.saltedge.com
MIT License
1 stars 4 forks source link

fetchFullProvidersListWithSuccess returns void #90

Open LetsSee opened 6 years ago

LetsSee commented 6 years ago

Hi!

It would be great if API calls will return NSURLSessionDataTask or array of tasks to give users possibility to control network calls. E.g:

- (void)fetchFullProvidersListWithSuccess:(void (^)(NSSet* providers))success failure:(SEAPIRequestFailureBlock)failure

will be

- (NSArray*)fetchFullProvidersListWithSuccess:(void (^)(NSSet* providers))success failure:(SEAPIRequestFailureBlock)failure

nemesis commented 6 years ago

Hi @LetsSee!

It seems I can't think of a good use case when you would need the NSURLSessionDataTask objects, which are managed by the SaltEdge iOS SDK classes. Can you provide further details on why would you need control over the requests?

Thanks

LetsSee commented 6 years ago

Of course:

  1. user initiate some API call on low speed network - loading hud appears - it takes too long and user wants to cancel this operation

  2. consider some long background task - we want to get state in some point (loading, finished, canceling, suspended)

....

nemesis commented 6 years ago

I see your point, but there are some constraints that will impede this from happening (currently).

The good thing is that you don't actually need the underlying session task objects to solve the two issues you described. The only drawback is that you won't be able to cancel the network operation, and I agree that it's a pity. We will surely consider your feedback when we'll implement a major update, and I'm leaving this issue open until that moment.

LetsSee commented 6 years ago

Thanks, @nemesis!

Please take into account those two issues are just examples, i can imagine much more cases.