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:
Adam Ernst 2016-12-08 07:28:10 -08:00 committed by Facebook Github Bot
parent 28e2f64d07
commit 574e3daf9f
1 changed files with 6 additions and 7 deletions

View File

@ -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;
}