Skip to content

Commit e0fb413

Browse files
committed
Fixed Client setup with and without Faye.
1 parent cb6e23e commit e0fb413

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Sources/Core/Client/Client+Setup.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@
88

99
import Foundation
1010
import Moya
11+
12+
#if canImport(Faye)
1113
import Faye
14+
#else
15+
extension Client {
16+
struct FayeClient { func disconnect() {} }
17+
static let fayeClient = FayeClient()
18+
}
19+
#endif
1220

1321
// MARK: - Client User Setup
1422

@@ -35,7 +43,10 @@ extension Client {
3543
/// - Returns: an object to cancel the request.
3644
@discardableResult
3745
public func setupUser<T: UserProtocol>(_ user: T, token: Token, completion: @escaping UserCompletion<T>) -> Cancellable {
38-
Client.fayeClient.disconnect()
46+
if NSClassFromString("Faye.Client") != nil {
47+
Client.fayeClient.disconnect()
48+
}
49+
3950
parseToken(token)
4051

4152
guard let currentUserId = currentUserId else {

0 commit comments

Comments
 (0)