-
-
Notifications
You must be signed in to change notification settings - Fork 878
Added NSNotifications being posted on every network request being sent/finished. #82
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
Conversation
I'm not super happy about using the default |
@protocol PFURLSessionDelegate <NSObject> | ||
|
||
- (void)urlSession:(PFURLSession *)session willPerformURLRequest:(NSURLRequest *)request; | ||
- (void)urlSession:(PFURLSession *)session didPerformURLRequest:(NSURLRequest *)request withURLResponse:(nullable NSURLResponse *)response; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we fail below the protocol level (e.g. user switches wifi off), this will be called without a URL Response, and no way to get the error out. Thoughts on having a way to get the underlying network error if one exists here?
There's also no good way to track cancelled requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this specific case - we don't really care about the result/error/cancellation, only about when the request is about to be sent and when request succeeded.
We don't really need an error right now, or a result, or cancelled status - that's why these are not implemented.
We can expand from here though at any given point of time.
Parse-specific - not really Will update in a bit. |
3433a9b
to
b1b1abd
Compare
@@ -49,11 +55,12 @@ - (instancetype)initWithDataSource:(id<PFInstallationIdentifierStoreProvider>)da | |||
clientKey:(NSString *)clientKey { | |||
NSURLSessionConfiguration *configuration = [[self class] _urlSessionConfigurationForApplicationId:applicationId | |||
clientKey:clientKey]; | |||
PFURLSession *session = [PFURLSession sessionWithConfiguration:configuration]; | |||
PFURLSession *session = [PFURLSession sessionWithConfiguration:configuration delegate:self]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is bad. Self may be re-assigned by init
, and then we have a dead delegate value. We should think about how to improve this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, the possibility of that happening is really really close to 0, so better testability (with injected everything) vs rare edge case scenario.
Added NSNotifications being posted on every network request being sent/finished.
This is required #74