Reputation: 359
I am new to DependencyInjection
and Swinject
and because of that i have question.
Let's say we have a ViewModel PersonList
with a list of Person
objects. We select one of the Person
and pass it to PersonDetails
which is something like PersonDetails(person:Person)
so basically we are selecting the Person
from the first ViewModel and passing it to the second ViewModel where the details of Person
will be displayed.
As i have understood with Swinject
we are to inject the dependencies at compile-time like
let container = Container()
container.register(Person.self) { _ in Person(name: "Someone") }
container.register(PersonDetails.self) { r in PersonDetails(person: r.resolve(Person.self))}
My question is we do not have the information at compile-time to know what kind of Person
will be selected in PersonList
so how can we inject the correctly selected Person
to PersonDetails
at Compile-time.
Upvotes: 0
Views: 304