mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Replace the ServiceLocator with direct dependency injection (#5548)
Removes the ServiceLocator singleton and instead directly injects the dependencies it was holding for more control over instantiation of the various component subtrees and better visibility over how they're being used.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
extension AnalyticsService {
|
||||
static func mock(_ clientOverride: AnalyticsClientProtocol? = nil, settings: AppSettings? = nil) -> AnalyticsService {
|
||||
let client: AnalyticsClientProtocol
|
||||
if let clientOverride {
|
||||
client = clientOverride
|
||||
} else {
|
||||
let mockClient = AnalyticsClientMock()
|
||||
mockClient.isRunning = false
|
||||
client = mockClient
|
||||
}
|
||||
|
||||
return .init(client: client, appSettings: settings ?? AppSettings())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user