parent
4e96784c98
commit
08dbc97c66
@ -1,29 +0,0 @@
|
||||
const { Container, DependencyInjector, Service } = require("./index")
|
||||
|
||||
class ServiceA extends Service {
|
||||
num = 1.34
|
||||
}
|
||||
|
||||
class ServiceB extends Service {
|
||||
static get services() {
|
||||
return ['service_a', 'num_pi']
|
||||
}
|
||||
|
||||
get num() {
|
||||
return this.service_a.num * this.num_pi
|
||||
}
|
||||
}
|
||||
|
||||
const ioc_container = new Container({
|
||||
service_a: ServiceA,
|
||||
})
|
||||
|
||||
ioc_container.register_singleton('num_pi', 3.141)
|
||||
ioc_container.register_service('service_b', ServiceB)
|
||||
|
||||
const ioc_di = new DependencyInjector(ioc_container)
|
||||
|
||||
global.cont = ioc_container
|
||||
global.di = ioc_di
|
||||
global.AA = ServiceA
|
||||
global.BB = ServiceB
|
Caricamento…
Fai riferimento in un nuovo problema