We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, I'm just wondering how you would inject parameters into a service.
Parameters like string, bool, int etc.
The text was updated successfully, but these errors were encountered:
When you're setting the dependency, you can just pass your arguments via the initialiser, e.g.
DependencyValues[\.userService] = MockUserService(myParameter1: 0, myParameter2: true)
Does this help?
Sorry, something went wrong.
This is you passing static values. Example
if the parameters change based on scenario probably it is a Codable or Equatable type rather than just String or Bool.
do you just create your key like this or how do you handle that
private struct UserServiceKey: DependencyKey { static var currentValue: UserService = MyUserService(model: SomeModel(name: "abc")) }
extension DependencyValues { var userService: UserService { get { Self[UserServiceKey.self] } set { Self[UserServiceKey.self] = newValue } } }
No branches or pull requests
Hi, I'm just wondering how you would inject parameters into a service.
Parameters like string, bool, int etc.
The text was updated successfully, but these errors were encountered: