-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,29 @@ | |
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@class PFURLSession; | ||
|
||
@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 commentThe 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 commentThe 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 can expand from here though at any given point of time. |
||
|
||
@end | ||
|
||
@interface PFURLSession : NSObject | ||
|
||
@property (nonatomic, weak, readonly) id<PFURLSessionDelegate> delegate; | ||
|
||
///-------------------------------------- | ||
/// @name Init | ||
///-------------------------------------- | ||
|
||
- (instancetype)init NS_UNAVAILABLE; | ||
- (instancetype)initWithConfiguration:(NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; | ||
+ (instancetype)sessionWithConfiguration:(NSURLSessionConfiguration *)configuration; | ||
- (instancetype)initWithConfiguration:(NSURLSessionConfiguration *)configuration | ||
delegate:(id<PFURLSessionDelegate>)delegate NS_DESIGNATED_INITIALIZER; | ||
|
||
+ (instancetype)sessionWithConfiguration:(NSURLSessionConfiguration *)configuration | ||
delegate:(id<PFURLSessionDelegate>)delegate; | ||
|
||
///-------------------------------------- | ||
/// @name Teardown | ||
|
@@ -52,7 +66,6 @@ NS_ASSUME_NONNULL_BEGIN | |
withCancellationToken:(nullable BFCancellationToken *)cancellationToken | ||
progressBlock:(nullable PFProgressBlock)progressBlock; | ||
|
||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
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.