Skip to content

Commit

Permalink
refactor a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kudo committed Feb 22, 2023
1 parent 7391f1a commit 5558c79
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class EXDevLauncherNetworkLogger: NSObject {
withJSONObject: ["method": "Network.requestWillBeSent", "params": params],
options: []
), let message = String(data: data, encoding: .utf8) {
inspectorPackagerConn?.sendWrappedEventToAllRemoteConnections(message)
inspectorPackagerConn?.sendWrappedEventToAllPages(message)
}
}

Expand Down Expand Up @@ -84,7 +84,7 @@ public class EXDevLauncherNetworkLogger: NSObject {
withJSONObject: ["method": "Network.responseReceived", "params": params],
options: []
), let message = String(data: data, encoding: .utf8) {
inspectorPackagerConn?.sendWrappedEventToAllRemoteConnections(message)
inspectorPackagerConn?.sendWrappedEventToAllPages(message)
}

params = [
Expand All @@ -99,7 +99,7 @@ public class EXDevLauncherNetworkLogger: NSObject {
],
options: []
), let message = String(data: data, encoding: .utf8) {
inspectorPackagerConn?.sendWrappedEventToAllRemoteConnections(message)
inspectorPackagerConn?.sendWrappedEventToAllPages(message)
}
}
}
Expand Down Expand Up @@ -150,14 +150,9 @@ extension RCTInspectorPackagerConnection {
/**
Sends message from native to inspector proxy
*/
func sendWrappedEventToAllRemoteConnections(_ event: String) {
guard let inspectorConnections =
value(forKey: "_inspectorConnections") as? [String: RCTInspectorLocalConnection]
else {
return
}
for pageId in inspectorConnections.keys {
perform(NSSelectorFromString("sendWrappedEvent:message:"), with: pageId, with: event)
func sendWrappedEventToAllPages(_ event: String) {
for page in RCTInspector.pages() {
perform(NSSelectorFromString("sendWrappedEvent:message:"), with: String(page.id), with: event)
}
}
}
Expand Down

0 comments on commit 5558c79

Please sign in to comment.