Skip to content

Commit c01069c

Browse files
committed
Add ConnectivityObserver to ServiceLocator back to make sure network monitoring works properly
1 parent dfbc04e commit c01069c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

WooCommerce/Classes/ServiceLocator/ServiceLocator.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ final class ServiceLocator {
7070
///
7171
private static var _receiptPrinter: PrinterService = AirPrintReceiptPrinterService()
7272

73+
/// Observer for network connectivity
74+
///
75+
private static var _connectivityObserver: ConnectivityObserver = DefaultConnectivityObserver()
76+
7377
// MARK: - Getters
7478

7579
/// Provides the access point to the analytics.
@@ -182,6 +186,12 @@ final class ServiceLocator {
182186
static var receiptPrinterService: PrinterService {
183187
_receiptPrinter
184188
}
189+
190+
/// Provides access point to the ConnectivityObserver.
191+
/// - Returns: An implementation of the ConnectivityObserver protocol.
192+
static var connectivityObserver: ConnectivityObserver {
193+
_connectivityObserver
194+
}
185195
}
186196

187197

@@ -292,6 +302,14 @@ extension ServiceLocator {
292302

293303
_receiptPrinter = mock
294304
}
305+
306+
static func setConnectivityObserver(_ mock: ConnectivityObserver) {
307+
guard isRunningTests() else {
308+
return
309+
}
310+
311+
_connectivityObserver = mock
312+
}
295313
}
296314

297315

0 commit comments

Comments
 (0)