Liftric / DIKit

Dependency Injection Framework for Swift, inspired by KOIN.
MIT License
102 stars 17 forks source link

Rethink lazy injection #34

Closed benjohnde closed 5 years ago

benjohnde commented 5 years ago

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.

benjohnde commented 5 years ago

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