Skip to content

Commit

Permalink
Merge branch 'fix/ReceiveTypo' into 'master'
Browse files Browse the repository at this point in the history
fix: Fixes `Receive` typo

See merge request PassiveLogic/public/graphqltransportws!7
  • Loading branch information
NeedleInAJayStack committed Jul 8, 2022
2 parents c3f398b + 5d7dfc5 commit e0f2a9e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/GraphQLTransportWS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Client<InitPayload: Equatable & Codable> {
messenger: Messenger
) {
self.messenger = messenger
messenger.onRecieve { message in
messenger.onReceive { message in
self.onMessage(message, self)

// Detect and ignore error responses.
Expand Down
2 changes: 1 addition & 1 deletion Sources/GraphQLTransportWS/Messenger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public protocol Messenger: AnyObject {
func send<S>(_ 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
Expand Down
2 changes: 1 addition & 1 deletion Sources/GraphQLTransportWS/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Server<InitPayload: Equatable & Codable> {
self.onExecute = onExecute
self.onSubscribe = onSubscribe

messenger.onRecieve { message in
messenger.onReceive { message in
self.onMessage(message)

// Detect and ignore error responses.
Expand Down
8 changes: 4 additions & 4 deletions Tests/GraphQLTransportWSTests/Utils/TestMessenger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand All @@ -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) {
Expand Down

0 comments on commit e0f2a9e

Please sign in to comment.