SwiftDI icon indicating copy to clipboard operation
SwiftDI copied to clipboard

Add ability to not inject lazily

Open AKoulabukhov opened this issue 5 years ago • 1 comments

Currently @Inject works lazily always. It means that object isn’t injected in fact until first call. It can lead to unexpected behavior. For example you have some broadcasting object which performs logic in init() method and inject it on a root level. Then you try to observe some changes but this object still isn’t created.

The proposal is to add an option to propertyWrapper or registration methods to make this behavior configurable.

AKoulabukhov avatar Dec 03 '19 19:12 AKoulabukhov

I agree with you, that is bad and LazyInit was an easy solution to avoid a recursive init for nested objects. Thanks for the issue and for example, it’ll help me to fix this.

SpectralDragon avatar Dec 03 '19 23:12 SpectralDragon