Skip to content

Commit

Permalink
fix: nwpath thread safety issue (#24)
Browse files Browse the repository at this point in the history
Co-authored-by: xiaoweii <[email protected]>
  • Loading branch information
zhu-xiaowei and xiaoweii authored Jul 31, 2023
1 parent db64731 commit ceecc65
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions Sources/Clickstream/Network/NetworkMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ protocol NetworkMonitor: AnyObject {
}

var currentNetWorkType: String = NetWorkType.UnKnow
var currentIsOnline: Bool = true

extension NWPathMonitor: NetworkMonitor {
var isOnline: Bool {
currentPath.status == .satisfied
}

var isOnline: Bool { currentIsOnline }
var netWorkType: String { currentNetWorkType }

func startMonitoring(using queue: DispatchQueue) {
start(queue: queue)
pathUpdateHandler = { path in
currentIsOnline = path.status == .satisfied
if path.usesInterfaceType(.wifi) {
currentNetWorkType = NetWorkType.Wifi
} else if path.usesInterfaceType(.cellular) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Clickstream/PackageInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
enum PackageInfo {
/// the clickstream analytics iOS sdk version
/// note: update and align the version with new tag version before committing new tag
static let version = "0.5.1"
static let version = "0.5.2"
}

0 comments on commit ceecc65

Please sign in to comment.