Skip to content
Discussion options

You must be logged in to vote

Hey @GarfieldJiang , we do not recommend using any sort of lazy resolution. The most likely reason to go for it is to bypass a circular dependency, and they are almost always a smell of a bad design choice.

Could I know more about your specific use case? There's not an answer that covers every possible workaround to lazy resolution.

Basically, there should be a way to define dependencies for your services. If you really cannot find an alternative to lazy resolution, you might bind the container as a service to achieve lazy resolution:

@injectable()
class Foo {
  readonly #container: Container;

  constructor(
    @inject(Symbol.for('container')
    container: Container,
  ) {
    this.#co…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by GarfieldJiang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants