Liftric/DIKit

Rethink lazy injection

benjohnde opened this issue · 1 comments

Currently lazy injection works through a different computed propery behaviour. Due to using an enum for @Inject it is mutating. Hence it is not really useful in a struct, as we are not allowed to alter a variable within a struct Cannot use mutating getter on immutable value: function call returns immutable value. And as 'mutating' may only be used on 'func' declarations we need a different approach.

We could possibly use @Inject var myService: MyServiceProtocol for lazy injection and var myService: MyServiceProtocol = resolve() for eager injection 🤔