Skip to content
Discussion options

You must be logged in to vote

Hey @mrtnstn,

sometimes cycles are unavoidable (we have some in our own framework). In order to make them lazy, you can do something like this:

class TypeSystem {
  private readonly provider: () => TypeProvider;
  constructor(services: TypeServices) {
    provider = () => services.TypeProvider; // <-- lazy evaluated service
  }
}

class TypeProvider {
  private readonly typeSystem: TypeSystem;
  constructor(services: TypeServices) {
    typeSystem = services.TypeSystem;
  }
}

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@mrtnstn
Comment options

Answer selected by mrtnstn
Comment options

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