refactor: inject IconPainter
in Shapes
#3042
Merged
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.
Previously, the shapes relied on
IconPainterProvider
to get theIconPainter
instance. This instance is now injected at shape instantiation byBpmnCellRenderer
. This reduces the adherence to a global state.This is a first step to remove the
IconPainterProvider
global state. This may be done later as it would imply to:render.iconPainter
propertyBpmnGraph
is initialized and configuredMinor functional change
Previously, when a shape was rendered, the current instance of the
IconPainter
was injected. If, between two renders, a new instance ofIconPainter
was configured viaIconPainterProvider
, it was used in the next render. This was a side-effect, not a desired feature, and was not documented.The interest is limited: we haven't yet seen a use case that requires it. The existing example of modifying the user task icon doesn't need it: in this case, we still want to display the customized icon.
With the changes proposed here, the behavior is modified. The
IconPainter
instance is defined when the library is initialized, so its modification inIconPainterProvider
only applies to new instances of the library. All rendering of a shape will always use theIconPainter
instance defined when the library was initialized.