Skip to content

Commit

Permalink
Merge pull request #4 from SwiftRex/fixInitialState
Browse files Browse the repository at this point in the history
Fix initial state
  • Loading branch information
luizmb authored May 17, 2021
2 parents 2ef748a + b1bd499 commit 98233b4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ where InputActionType == ReachabilityEvent,

send(event: .gotOffline,
when: ![.wiredEthernet, .wifi, .cellular].contains(where: path.usesInterfaceType),
previously: \.connectivity != .none,
previously: \.connectivity != .offline,
state: state),

send(event: .becameExpensive,
Expand Down
2 changes: 1 addition & 1 deletion Sources/ReachabilityMiddleware/ReachabilityReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension Reducer where ActionType == ReachabilityEvent, StateType == Reachabili
case .gotOffline:
state = .init(
isMonitoring: state.isMonitoring,
connectivity: .none,
connectivity: .offline,
isExpensive: state.isExpensive,
isConstrained: state.isConstrained
)
Expand Down
6 changes: 4 additions & 2 deletions Sources/ReachabilityMiddleware/ReachabilityState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ extension ReachabilityState {
public static var initial: ReachabilityState {
.init(
isMonitoring: false,
connectivity: .none,
connectivity: .unknown,
isExpensive: true,
isConstrained: true
)
}
}

public enum ConnectedInterface: String, Codable, Hashable {
/// Initial state, we don't know yet the state of the interface
case unknown
/// cellular (3G, LTE, 5G networks)
case cellular
/// Wi-fi, including Personal Hotpots
case wifi
/// Wired Ethernet
case wired
/// Disconnected
case none
case offline
}

0 comments on commit 98233b4

Please sign in to comment.