-
Notifications
You must be signed in to change notification settings - Fork 36
Completing NSOperation before executing callback #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
… previous AFHTTPRequestOperationManager behaviour.
|
I wonder what's the standard behavior of |
|
The standard In terms of why I implemented it like I did, I didn't change the behavior consciously, but rather just because this is how I've always done it and because I personally hate this "call completion block after dependent operations probably have started" behavior. It's equivalent to a notification (that you know it will fire some time after the operation finishes, but no assurances of precisely when). For example, let's say you queue an authentication operation and a bunch of requests that are dependent upon that authentication finishing. But, if the authentication request failed, I'd like to cancel the other network operations that were queued and dependent upon the authentication operation. But if the completion callback takes place after the authentication operation completes, I don't have an opportunity to cancel those other operations. You could achieve this by employing some So while I wrote this for (what I consider to be) well considered reasons, in retrospect I think that you're right, that this isn't consistent with how AFNetworking has historically handled its completion blocks. I should probably reconsider this. If you don't mind, I'm going to stew on this a bit (and give others a chance to chime in) before I change this. |
|
Thanks for the quick response to this. I agree that it would be better if the completion block of an You are right that logic in the callbacks should not be relying on state of other operations in the queue. I am working with legacy code that I am trying to bring up to date, and having looked at my particular case again, I think the best approach for me is actually to not use an I'll leave it up to you to mull it over anyhow. |
|
Re your retiring of Re this particular push request, as I review it, I see you've changed the sequence in which operations are completed and when the completion handler is called. But if I started to pull on this thread (make it consistent with My final reservation is that this would be a non-backward compatible change to this repo (not that there are enough people using it, nor are the likely to be doing anything contingent on the old behavior). But if I'm going to make a non-backward compatible change, I'd probably be inclined to do this within the context of the more radical refactoring. Bottom line, all said and done, unless there is an outpouring of feedback voting for this pull request, or more dramatic refactoring, I'm inclined to let sleeping dogs lie. Let's see what feedback we get on this pull request and make a decision from there. |
I've just updated an old project from AFNetworking 1.x to 3.1, and found your wrapper very useful.
Maybe this change seems a little pedantic, but it solves an issue I had where I inspect the number of operations in the queue in the success callback. With AFNetworking 1.x code, the operation would have been removed from the queue before the callback, meaning I could see if the queue was empty. This change fixes the issue.