-
While working on a type system for my Langium language, I ran into this error message: It makes some sense to me, because I have both a TypeSystem and a TypeProvider module that depend on each other. My question is how to resolve this? How do I make the module 'lazy', as suggested in the error message? If all else fails, I could consider to merge the two modules into one, but I would prefer to keep some separation of concerns. The referenced documentation does not seem to be written yet :-( |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
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;
}
} |
Beta Was this translation helpful? Give feedback.
-
There's an issue about writing the missing documentation page: eclipse-langium/langium-website#39 |
Beta Was this translation helpful? Give feedback.
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: