diff --git a/README.md b/README.md index 736dd38..65b6646 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,12 @@ import GraphQLTransportWS /// Messenger wrapper for WebSockets class WebSocketMessenger: Messenger { private weak var websocket: WebSocket? - private var onRecieve: (String) -> Void = { _ in } + private var onReceive: (String) -> Void = { _ in } init(websocket: WebSocket) { self.websocket = websocket websocket.onText { _, message in - self.onRecieve(message) + self.onReceive(message) } } @@ -41,8 +41,8 @@ class WebSocketMessenger: Messenger { websocket.send(message) } - func onRecieve(callback: @escaping (String) -> Void) { - self.onRecieve = callback + func onReceive(callback: @escaping (String) -> Void) { + self.onReceive = callback } func error(_ message: String, code: Int) { diff --git a/Sources/GraphQLTransportWS/Client.swift b/Sources/GraphQLTransportWS/Client.swift index eb88476..b340e98 100644 --- a/Sources/GraphQLTransportWS/Client.swift +++ b/Sources/GraphQLTransportWS/Client.swift @@ -25,7 +25,7 @@ public class Client { messenger: Messenger ) { self.messenger = messenger - messenger.onRecieve { message in + messenger.onReceive { message in self.onMessage(message, self) // Detect and ignore error responses. diff --git a/Sources/GraphQLTransportWS/Messenger.swift b/Sources/GraphQLTransportWS/Messenger.swift index 37845c3..6c82fce 100644 --- a/Sources/GraphQLTransportWS/Messenger.swift +++ b/Sources/GraphQLTransportWS/Messenger.swift @@ -12,7 +12,7 @@ public protocol Messenger: AnyObject { func send(_ message: S) -> Void where S: Collection, S.Element == Character /// Set the callback that should be run when a message is recieved - func onRecieve(callback: @escaping (String) -> Void) -> Void + func onReceive(callback: @escaping (String) -> Void) -> Void /// Close the messenger func close() -> Void diff --git a/Sources/GraphQLTransportWS/Server.swift b/Sources/GraphQLTransportWS/Server.swift index 4f70d72..a3b2d14 100644 --- a/Sources/GraphQLTransportWS/Server.swift +++ b/Sources/GraphQLTransportWS/Server.swift @@ -41,7 +41,7 @@ public class Server { self.onExecute = onExecute self.onSubscribe = onSubscribe - messenger.onRecieve { message in + messenger.onReceive { message in self.onMessage(message) // Detect and ignore error responses. diff --git a/Tests/GraphQLTransportWSTests/Utils/TestMessenger.swift b/Tests/GraphQLTransportWSTests/Utils/TestMessenger.swift index 1585aaf..1e7c274 100644 --- a/Tests/GraphQLTransportWSTests/Utils/TestMessenger.swift +++ b/Tests/GraphQLTransportWSTests/Utils/TestMessenger.swift @@ -9,7 +9,7 @@ import Foundation /// or risk them being deinitialized early class TestMessenger: Messenger { weak var other: TestMessenger? - var onRecieve: (String) -> Void = { _ in } + var onReceive: (String) -> Void = { _ in } let queue: DispatchQueue = .init(label: "Test messenger") init() {} @@ -21,12 +21,12 @@ class TestMessenger: Messenger { // Run the other message asyncronously to avoid nesting issues queue.async { - other.onRecieve(String(message)) + other.onReceive(String(message)) } } - func onRecieve(callback: @escaping (String) -> Void) { - self.onRecieve = callback + func onReceive(callback: @escaping (String) -> Void) { + self.onReceive = callback } func error(_ message: String, code: Int) {