LeetCode-OpenSource/asuka

Is @asuka/di has many breaking changes from v0.3.3 to v0.3.4?

TIS-OMiddle opened this issue · 0 comments

d96b65e#diff-b219ef22b92d2ebf9ffe305f35b9bd96

I notice this commit remove the InjectableConfig param from Injectable , and InjectableFactory has been removed.

The example code in README.md isn't work now:

import { Inject, InjectionToken, Injectable, InjectableFactory, ValueProvider } from '@asuka/di'
import Axios from 'axios'

const token = new InjectionToken<Axios>('Axios client')

const provider: ValueProvider = {
  provide: token,
  useValue: Axios,
}

@Injectable({
  providers: [provider],
})
class HttpClient {
  constructor(@Inject(token) public axios: Axios) { }
}

const client = InjectableFactory.getInstance(HttpClient)
expect(client).to.be.instanceof(HttpClient)
expect(client.axios).to.equal(Axios)

I have to use rootInjector.addProviders to replace any InjectableConfig used in @Injectable now?