Skip to content

Commit

Permalink
fix: Handling of leap edge options
Browse files Browse the repository at this point in the history
  • Loading branch information
rishi8094 committed Sep 13, 2022
1 parent 22d2fed commit 4e7b50a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 32 deletions.
17 changes: 11 additions & 6 deletions Sources/LeapEdge/LeapEdge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ final public class LeapEdge: WebSocketDelegate {

public init(
auth: AuthenticationParameters,
opts: Partial<InitOptions>? = nil
opts: InitOptions? = nil
) {
self.auth = auth
self.socket = nil
self.heartbeat = nil
self.heartbeatInterval = nil
self.lastServerHeartbeatAck = nil
self.connectionState = .idle
self.options = InitOptions(
socketUrl: opts?[\.socketUrl] ?? DEFAULT_ENDPOINT,
debug: opts?[\.debug] ?? false
)
self.options = opts ?? InitOptions()
self.emitter = Emitter()
self.throttler = Throttler(minimumDelay: 1.0)
}
Expand Down Expand Up @@ -239,7 +236,15 @@ extension LeapEdge {

public struct InitOptions {
var socketUrl: URL
let debug: Bool
var debug: Bool

public init(
socketUrl: URL? = nil,
debug: Bool? = nil
) {
self.socketUrl = socketUrl ?? DEFAULT_ENDPOINT
self.debug = debug ?? false
}
}

public enum ConnectionState: String {
Expand Down
23 changes: 0 additions & 23 deletions Sources/LeapEdge/Utils/Partial.swift

This file was deleted.

4 changes: 1 addition & 3 deletions Tests/LeapEdgeTests/LeapEdgeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import XCTest

final class LeapEdgeTests: XCTestCase {
func testConnection() throws {
var options: LeapEdge.Partial<LeapEdge.InitOptions> = .init()
options[\.debug] = false
let leap = LeapEdge(auth: .init(token: nil, projectId: "test"), opts: options)
let leap = LeapEdge(auth: .init(token: nil, projectId: "test"), opts: .init(debug: false))
leap.connect()
let expectation = expectation(description: "Will connect and receive a message")

Expand Down

0 comments on commit 4e7b50a

Please sign in to comment.