Allow override of model element registration in DI #424
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow the element registration from the dependency injection to be overridden by another
ContainerModule
. This comes in handy when working with exported containers from thesprotty-library
or when sharing aContainerModule
when only a subset of model elements need a new registration.This introduces a new helper function
overrideModelElement
to be used instead ofconfigureModelElement
in theContainerModule
Example:
In this scenario,
myElementType
elements will first be linked toMyElementImplA
andMyElementViewA
before being linked toMyElementImplB
andMyElementViewB
.If the order of the functions
container.load(...)
are reversed, so is the link between the element type and its implementation/view.Error handling:
By design, we can only override an element that has already been configured.
configureModelElement
on an element type that is already registered will throw an erroroverrideModelElement
on an element type that is not already registered will throw an error