Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to function from closure #613

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Sources/Realtime/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
Loading