From 5f3ba57128dc1d84e9d848e2f47dcf381c213b8a Mon Sep 17 00:00:00 2001 From: zunda Date: Thu, 24 Oct 2024 02:32:05 +0900 Subject: [PATCH] change to function from closure --- Sources/Realtime/Defaults.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Realtime/Defaults.swift b/Sources/Realtime/Defaults.swift index e74f08bc..5ae05851 100644 --- a/Sources/Realtime/Defaults.swift +++ b/Sources/Realtime/Defaults.swift @@ -33,19 +33,19 @@ public enum Defaults { public static let heartbeatLeeway: DispatchTimeInterval = .milliseconds(10) /// Default reconnect algorithm for the socket - public static let reconnectSteppedBackOff: (Int) -> TimeInterval = { tries in + public static func reconnectSteppedBackOff(tries: Int) -> TimeInterval { tries > 9 ? 5.0 : [0.01, 0.05, 0.1, 0.15, 0.2, 0.25, 0.5, 1.0, 2.0][tries - 1] } /** Default rejoin algorithm for individual channels */ - public static let rejoinSteppedBackOff: (Int) -> TimeInterval = { tries in + public static func rejoinSteppedBackOff(tries: Int) -> TimeInterval { tries > 3 ? 10 : [1, 2, 5][tries - 1] } public static let vsn = "2.0.0" /// Default encode function, utilizing JSONSerialization.data - public static let encode: (Any) -> Data = { json in + public static func encode(json: Any) -> Data { try! JSONSerialization .data( withJSONObject: json, @@ -54,7 +54,7 @@ public enum Defaults { } /// Default decode function, utilizing JSONSerialization.jsonObject - public static let decode: (Data) -> Any? = { data in + public static func decode(data: Data) -> Any? { guard let json = try? JSONSerialization