This repository has been archived by the owner on Nov 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d2c445
commit b92c9c3
Showing
4 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// CalculatorClient.swift | ||
// Calcium | ||
// | ||
// Created by Roman Podymov on 11/08/2024. | ||
// Copyright © 2024 Calcium. All rights reserved. | ||
// | ||
|
||
import CalciumCommon | ||
import ComposableArchitecture | ||
import Resolver | ||
|
||
@DependencyClient | ||
struct CalculatorClient { | ||
var calculateValue: (String, String, CalciumCommon.Operation) -> String = { _, _, _ in "" } | ||
} | ||
|
||
extension DependencyValues { | ||
var calculator: CalculatorClient { | ||
get { self[CalculatorClient.self] } | ||
set { self[CalculatorClient.self] = newValue } | ||
} | ||
} | ||
|
||
extension CalculatorClient: DependencyKey { | ||
static let liveValue = CalculatorClient( | ||
calculateValue: { | ||
@Injected var calculator: Calculator | ||
|
||
return calculator.calculateValue(lhs: $0, rhs: $1, operation: $2) | ||
} | ||
) | ||
} | ||
|
||
extension CalculatorClient: TestDependencyKey { | ||
static let previewValue = { | ||
@Injected var calculator: Calculator | ||
|
||
return Self(calculateValue: { | ||
NativeCalculator().calculateValue(lhs: $0, rhs: $1, operation: $2) | ||
}) | ||
}() | ||
|
||
static let testValue = previewValue | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
plugins { | ||
kotlin("multiplatform").version("2.0.20-Beta2").apply(false) | ||
kotlin("multiplatform").version("2.0.20-RC").apply(false) | ||
} |