Closed evgeniy-bizhanov closed 5 years ago
oh... this case not worked now. Lazy not worked with many. My bad.
I'm special fix in version 3.8.1 for only this case.
by the way DIPart's load is not called, when it's part of DIFramework
container.append(part: Part.self)
through container is work
but through DIFramework does not
@evgeniy-bizhanov ... but tests worked. for example:
let container = DIContainer()
container.register(FooService.init)
.as(check: ServiceProtocol.self){$0}
container.register(BarService.init)
.as(check: ServiceProtocol.self){$0}
let services: [Lazy<ServiceProtocol>] = many(*container)
XCTAssertEqual(services.count, 2)
XCTAssertNotEqual(services[0].value.foo(), services[1].value.foo())
Your used 3.8.1 version?
about DIPart and DIFramework - it's works (tested on modular big project). Maybe you not fully understand how work DIFramework, but normally case it doesn't matter. Worked code:
let container = DIContainer()
container.append(framework: YourFramework.self)
class YourFramework: DIFramework {
static func load(container: DIContainer) {
container.append(part: YourPart.self)
}
}
class YourPart: DIPart {
static func load(container: DIContainer) {
container.register(...)
}
}
yes, it was 3.8.1, but seems it was cached( I reinstalled pod and it worked thanks for the quick support:)
I found that resolving Lazy property by tag also not working..
let lazy: Lazy<Service> = by(tag: EmailService.self, on: *container)
info: Not found type: Lazy
with tag: EmailService Fatal error: Can't resolve type Service. For more information see logs.: file 2019-09-15 15:21:51.149208+0700 ForFun[12579:885258] Fatal error: Can't resolve type Service. For more information see logs.: file error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been returned to the state before expression evaluation.
:( I will see on Monday
@evgeniy-bizhanov fix in version 3.8.2.
It works, thanks!:)
Hi,
let test: [Lazy<Provider>] = [*container]
is work butlet test: [Lazy<Provider>] = many(*container)
doesn'twhat workaround could be? thanx