Some opinion & question after trying this library #348
Replies: 1 comment
-
Hi @HotFryingPan, I have some answers to you questions below:
Is this a concern? We feel that there are a lot of ill-defined concepts concerning dependencies, and so we rather not get entangled in a semantics debate. The library is modeled on storing all dependencies in a global, and in particular in a
Would you rather your app crash when asking for a dependency that has not been provided? There are two ends of the spectrum:
And so our library tries to strike a middle ground between these two approaches. We do store dependencies in a global (a
Do you know of other dependency libraries out there that are not opinionated?
I personally find it hard to believe that your build is demonstrably slower. The protocol UseCase {
func method()
}
struct UnimplementedUserCase: UseCase {
func method() {
reportIssue("Unimplemented: \(Self.self).\(#function)")
}
} This is a great default implementation of the And further, if you use the struct-style of dependencies, along with the @DependencyClient
struct Client {
var fetch: () async throws -> Int
}
extension Client: TestDependencyKey {
static var testValue: Client { Client() }
} The So, what you are seeing is indeed the intended behavior of the library and not likely to substantially change unless there is a way to still achieve all the things we are currently. |
Beta Was this translation helpful? Give feedback.
-
Hi @stephencelis @mbrandonw,
Before starting, thanks for making this lib and I'm sorry if Discussion is not the appropriate place to share about this. Please let me know & I'll move the discussion to the appropriate place 🙇
I was jumping & trying to migrate my app to use this library for a while and I want to share what I found, feel, and concerns after migrating to this lib:
testValue
inside theDependencyKey
orTestDependencyKey
. ( I put the code below for example of what I did)Here's my old code using simple constructor injection
And here's after using this library
Beta Was this translation helpful? Give feedback.
All reactions