[REFACTOR] Split the code of BpmnElementsRegistry
and the code of its collaborators
#2803
Closed
3 tasks done
Over time,
BpmnElementsRegistry
has become a veritable monster. It was originally intended to be responsible for the retrieval of model elements and their associated visual information.But then we added methods to handle CSS classes, overlays and cell styling. It now has too many responsibilities, and we should consider splitting up its public API.
To prepare for this split, we first have to split the internal code, especially as some parts are very tightly coupled.
This will also prepare the code for tree-shaking and will introduce better separation of concerns.
The overlays part has already been managed in #2800
There are 2 parts in the code and here is how we can proceed (this has been followed in #2800):
BpmnElementsRegistry
can move to other "registry" files. It is generally glue codeIn addition, extract dedicated interfaces for all new registries. This will:
Possible drawback in HTML API: the split into several interfaces may require more navigation for readers. This is already the case for the split of existing type like
ShapeUpdate
. There is nothing we can do to improve that.Challenges
Notes:
0.38.1
The main issue for this change is the coupling which has been introduced in #2732 and that had already been noticed at that time:
StyleManager
(mxGraph related) andCssRegistry
(domain specific) know each other introducing a cyclic dependency. The domain code can know the mxGraph code but not the opposite.This was introduced to ensure that the style update correctly works with the CSS classes management.
The two elements include caches that need to be cleared while loading a new model. This part is probably coupled and should be improved.
Proposed renaming and file organization
registry/css-registry.ts
CssRegistry
class intoCssClassesCache
CssClassesRegistry
as entry point of CSS classes managementmxgraph/
StyleUpdater
class with the style part of the existingGraphCellUpdater
. Find a better name forStyleManager
that should not been exported anymore as it should only be used byStyleUpdater
CssClassesUpdater
class with the style part of the existingGraphCellUpdater
GraphCellUpdater
Note: in the existing code of
GraphCellUpdater
,this.graph.model.setStyle(...)
should use themodel
constant directly instead of passing by thegraph
.Proposal for new interfaces
in registry/types.ts, add the following interface
Tasks
The text was updated successfully, but these errors were encountered: