{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/5321","labels_url":"https://api.github.com/repos/facebook/react-native/issues/5321/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/5321/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/5321/events","html_url":"https://github.com/facebook/react-native/pull/5321","id":126759673,"number":5321,"title":"Make the RCTSRWebSocketDelegate protocol part of RCTWebSocketModule public","user":{"login":"philikon","id":54918,"avatar_url":"https://avatars.githubusercontent.com/u/54918?v=3","gravatar_id":"","url":"https://api.github.com/users/philikon","html_url":"https://github.com/philikon","followers_url":"https://api.github.com/users/philikon/followers","following_url":"https://api.github.com/users/philikon/following{/other_user}","gists_url":"https://api.github.com/users/philikon/gists{/gist_id}","starred_url":"https://api.github.com/users/philikon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philikon/subscriptions","organizations_url":"https://api.github.com/users/philikon/orgs","repos_url":"https://api.github.com/users/philikon/repos","events_url":"https://api.github.com/users/philikon/events{/privacy}","received_events_url":"https://api.github.com/users/philikon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react-native/labels/CLA%20Signed","name":"CLA Signed","color":"e7e7e7"},{"url":"https://api.github.com/repos/facebook/react-native/labels/GH%20Review:%20review-needed","name":"GH Review: review-needed","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-01-14T22:08:32Z","updated_at":"2016-01-14T23:00:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/react-native/pulls/5321","html_url":"https://github.com/facebook/react-native/pull/5321","diff_url":"https://github.com/facebook/react-native/pull/5321.diff","patch_url":"https://github.com/facebook/react-native/pull/5321.patch"},"body":"This allows consumers to subclass and extend `RCTWebSocketModule` and make use of the `RCTSRWebSocketDelegate` methods.\r\n\r\nThe use case here is to do some pre-processing of WebSocket data before handing it off to JS. Consumers could that in the following way:\r\n\r\n```\r\n#import \"RCTBridgeModule.h\"\r\n#import \"RCTWebSocketModule.h\"\r\n\r\n@interface MyWebSocketModule : RCTWebSocketModule\r\n@end\r\n\r\n@implementation MyWebSocketModule\r\n\r\n// Don't use RCT_EXPORT_MODULE macro for this so we replace the existing RCTWebSocketModule.\r\n+ (NSString *)moduleName { return @\"RCTWebSocketModule\"; }\r\n\r\nRCT_EXTERN_METHOD(connect:(NSURL *)URL socketID:(nonnull NSNumber *)socketID)\r\nRCT_EXTERN_METHOD(send:(NSString *)message socketID:(nonnull NSNumber *)socketID)\r\nRCT_EXTERN_METHOD(close:(nonnull NSNumber *)socketID)\r\n\r\n- (void)webSocket:(RCTSRWebSocket *)webSocket didReceiveMessage:(id)message\r\n{\r\n  [super webSocket:webSocket didReceiveMessage:[DoSomethingWith message]];\r\n}\r\n\r\n@end\r\n```\r\n\r\n... and then returning a `MyWebSocketModule` instance from the app's `[RCTBridgeDelegate extraModulesForBridge]` method."},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/171809089","html_url":"https://github.com/facebook/react-native/pull/5321#issuecomment-171809089","issue_url":"https://api.github.com/repos/facebook/react-native/issues/5321","id":171809089,"user":{"login":"philikon","id":54918,"avatar_url":"https://avatars.githubusercontent.com/u/54918?v=3","gravatar_id":"","url":"https://api.github.com/users/philikon","html_url":"https://github.com/philikon","followers_url":"https://api.github.com/users/philikon/followers","following_url":"https://api.github.com/users/philikon/following{/other_user}","gists_url":"https://api.github.com/users/philikon/gists{/gist_id}","starred_url":"https://api.github.com/users/philikon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philikon/subscriptions","organizations_url":"https://api.github.com/users/philikon/orgs","repos_url":"https://api.github.com/users/philikon/repos","events_url":"https://api.github.com/users/philikon/events{/privacy}","received_events_url":"https://api.github.com/users/philikon/received_events","type":"User","site_admin":false},"created_at":"2016-01-14T23:00:35Z","updated_at":"2016-01-14T23:00:35Z","body":"Oh. That makes total sense. TIL.\r\n\r\nThanks @nicklockwood!"}}