Liftric/DIKit

Resolving by name

benjohnde opened this issue · 2 comments

Add the ability to resolve components by name

@benjohnde which components should be resolvable?

It was more like a feature idea. Currently Components are registered with the register method, see here DependencyContainer%2BRegister.swift#L17.

To be resolved later on it uses the tag propery of a Component, cf. Component.swift#L21.

So my idea was to have the possibility to define a name: String to register the Component.

So, for instance that you could do something like the following:

register(with: "backendSlave", Backend() as BackendProtocol)
// and later on:
var backendSlave: BackendProtocol = inject("backendSlave")

Was just some idea I had in mind.