-
Notifications
You must be signed in to change notification settings - Fork 82
Add dependency-injection support to LayoutRegistry #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dependency-injection support to LayoutRegistry #234
Conversation
I'm not sure how the default layouts should be registered. Ideally, we want to be able to remove them, or to associate a different implementation with the same key (e.g. providing our own implementation for the "vbox" layout). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @CamilleLetavernier, thanks for the contribution!
You can look at the action handler registrations to see how to define the registration in a way that the default layouts can be overridden:
https://github.com/eclipse/sprotty/blob/6b6f109246bfa56ca11c1a72c0da920d1e194bab/src/base/actions/action-handler.ts#L73-L87
The utility function binds the constructor to itself, so users can override that by rebinding the constructor.
@spoenemann Maybe we should apply this pattern to all classes that are multiinjected. I haven't had a detailed look yet, but I know that there at least some multiinjected classes that are not bound to itself before they are bound to the multiinjected key. |
Yes, that makes sense! In that case it can be expressed more simply: bind(MoveMouseListener).toSelf().inSingletonScope();
bind(TYPES.MouseListener).toService(MoveMouseListener); |
Thanks for the reviews! I've addressed the simple comments (Using logger & sorting the TYPES). I also noticed that the tests were broken, because manually instantiating a LayoutRegistry no longer registers the 3 default layouts; it should be fixed now. I still need to add a "configureLayout" function, similar to the Action handlers, but I won't have time to do that (and test that with my use cases) properly this week; so I'll keep it for later :) |
Signed-off-by: Camille Letavernier <[email protected]>
Signed-off-by: Camille Letavernier <[email protected]>
a83735e
to
243197b
Compare
I've rebased the branch on the current master, and added a configureLayout() function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
@tortmayr is there already an issue about this? |
I don't think so. I created #239 to track this. |
Modify the LayoutRegistry to support LayoutRegistrations via dependency-injection, similar to how it's done for other registries