palasthotel / wind

dependency injection container in pure swift
9 stars 2 forks source link

Add more Metadata to Resolving Dependencies #1

Closed mkernel closed 7 years ago

mkernel commented 7 years ago

Currently, the delegation pattern used to resolve dependencies is not capable of seeing wether a component is fully resolved or not.

Therefore the order of registration may matter and may produce stack overflows, unresolved dependencies or crashes.

We need a way to see wether a component needs a certain resolver or not. And we need to detect wether a resolver is ready to use or not in order to follow the dependency graph.

My current idea to solve this problem: Extend the Resolver Interface by a new function resolutionpossible(on consumer:Component) -> Bool With that function the Container can check wether a Resolver is needed by a certain component.

To know wether a certain Resolver is ready to use, the container can simply collect all resolvers in another collection once they're done resolving their own dependencies.

mkernel commented 7 years ago

Fixed in 859453a9a7fbd8349d28b762abe76bdd219bc71b