Clean up RCTWebSocketObserver
Summary: Avoid using properties where unnecessary; stick to only one way to modify the delegate. Reviewed By: javache Differential Revision: D4296351 fbshipit-source-id: 94d0e3c90904ed584f691a3f28a15a7ac450c3e1
This commit is contained in:
parent
28e2f64d07
commit
574e3daf9f
|
@ -22,23 +22,21 @@
|
|||
|
||||
@interface RCTWebSocketObserver : NSObject <RCTSRWebSocketDelegate> {
|
||||
NSURL *_url;
|
||||
RCTSRWebSocket *_socket;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) RCTSRWebSocket *socket;
|
||||
@property (nonatomic, weak) id<RCTWebSocketProxyDelegate> delegate;
|
||||
@property (nonatomic, strong) dispatch_semaphore_t socketOpenSemaphore;
|
||||
- (instancetype)initWithURL:(NSURL *)url;
|
||||
|
||||
- (instancetype)initWithURL:(NSURL *)url delegate:(id<RCTWebSocketProxyDelegate>)delegate;
|
||||
@property (nonatomic, weak) id<RCTWebSocketProxyDelegate> delegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTWebSocketObserver
|
||||
|
||||
- (instancetype)initWithURL:(NSURL *)url delegate:(id<RCTWebSocketProxyDelegate>)delegate
|
||||
- (instancetype)initWithURL:(NSURL *)url
|
||||
{
|
||||
if ((self = [self init])) {
|
||||
_url = url;
|
||||
_delegate = delegate;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -131,7 +129,8 @@
|
|||
observer.delegate = delegate;
|
||||
}
|
||||
} else {
|
||||
RCTWebSocketObserver *newObserver = [[RCTWebSocketObserver alloc] initWithURL:url delegate:delegate];
|
||||
RCTWebSocketObserver *newObserver = [[RCTWebSocketObserver alloc] initWithURL:url];
|
||||
newObserver.delegate = delegate;
|
||||
[newObserver start];
|
||||
_sockets[key] = newObserver;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue