There’s something I don’t quite understand: when you have an object bound in a ConnectionContainerModule, can it be injected into an object in another connection container module than the one it was defined in? If yes, how does the correct object get picked? By correct I mean the one bound to the same connection.
[original thread by Thomas Mäder]
Conceptually you can think that there is the application-wide scope and scope per a connection. Objects from a connection scope can access (via injection) any object from connection and application scopes. Objects from the application scope cannot access objects from any connection scope.
From implementation view, a new DI container is created for each connection and all connection container modules are loaded into it following topological order of extensions contributing them. Happens here: https://github.com/theia-ide/theia/blob/9fe8aa63bb2b2568abbd5f7e49b36b57c49e2a49/packages/core/src/node/messaging/messaging-contribution.ts#L162
Regarding your question: yes, you can inject an object contributed by one module into an object contributed by another since they belong to the same scope (DI container).