jecht83
(Julio Montoya)
1
While working with dependency injection in other projects i was able to create a dependency based in a previously registered dependency like the following example in Swinject
let container = Container()
container.register(Animal.self) { _ in Cat(name: "Mimi") }
container.register(Person.self) { r in
PetOwner(pet: r.resolve(Animal.self)!)
}
I have successfully created a single dependency in TCA but
Is there a way to do something like the previous code with TCA dependencies?
kamcma
(Kyle McMahon)
2
It is fine for a dependency value to reference another dependency. (As long as the references are not circular.)
For example, a database client. The test and preview values likely do not need to reference other dependencies, but the live value may need to access an environment values client to get a connection string. Something like that. Usually it is the live values of dependencies that need to reference other dependencies.
kamcma
(Kyle McMahon)
3
Another reference, the one I had been searching for before I found the other.