Skip to content

Commit

Permalink
Start exposing RCTWebSocketObserver using a protocol
Browse files Browse the repository at this point in the history
Reviewed By: javache

Differential Revision: D4296387

fbshipit-source-id: 33f92c36168dcb18356d0ccdaf902a84634d94b7
  • Loading branch information
adamjernst authored and Martin Konicek committed Dec 12, 2016
1 parent 7a8410b commit 48cb8d3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Libraries/WebSocket/RCTWebSocketManager.h
Expand Up @@ -12,6 +12,9 @@

#if RCT_DEV // Only supported in dev mode

@interface RCTWebSocketObserver : NSObject <RCTWebSocketObserver>
@end

@interface RCTWebSocketManager : NSObject <RCTWebSocketProxy>
@end

Expand Down
13 changes: 5 additions & 8 deletions Libraries/WebSocket/RCTWebSocketManager.m
Expand Up @@ -20,18 +20,15 @@

#pragma mark - RCTWebSocketObserver

@interface RCTWebSocketObserver : NSObject <RCTSRWebSocketDelegate> {
@interface RCTWebSocketObserver () <RCTSRWebSocketDelegate>
@end

@implementation RCTWebSocketObserver {
NSURL *_url;
RCTSRWebSocket *_socket;
}

- (instancetype)initWithURL:(NSURL *)url;

@property (nonatomic, weak) id<RCTWebSocketProxyDelegate> delegate;

@end

@implementation RCTWebSocketObserver
@synthesize delegate = _delegate;

- (instancetype)initWithURL:(NSURL *)url
{
Expand Down
7 changes: 7 additions & 0 deletions React/Base/RCTWebSocketProxy.h
Expand Up @@ -12,6 +12,13 @@

#if RCT_DEV // Only supported in dev mode

@protocol RCTWebSocketProxyDelegate;

@protocol RCTWebSocketObserver
- (instancetype)initWithURL:(NSURL *)url;
@property (nonatomic, weak) id<RCTWebSocketProxyDelegate> delegate;
@end

@protocol RCTWebSocketProxy

+ (instancetype)sharedInstance;
Expand Down

0 comments on commit 48cb8d3

Please sign in to comment.