Is your feature request related to a problem? Please describe.
Plugins in bpmn-visualization-addons can register event listeners, allocate objects, keep internal references, or start timers.
Since the core library now provides a dispose() method on BpmnVisualization (see process-analytics/bpmn-visualization-js#3415), the core instance can clean up resources, but plugins still cannot.
This may create memory leaks in long-running applications or SPA environments.
Describe the solution you'd like
Add a new plugin lifecycle hook to let plugins release their resources when the underlying BpmnVisualization is disposed.
Proposed changes:
- Add a new optional method
onDispose(): void on plugins
- Add a new
onConfigure(bv) hook for consistency (as onDispose), while keeping configure(bv) for backward compatibility
- During disposal, the addons wrapper should:
- call
plugin.onDispose?.()
- then call
bpmnVisualization.dispose()
Example API:
export interface Plugin {
readonly id: string;
onConfigure?(bv: BpmnVisualization): void;
onDispose?(): void;
// backward compatibility, probably to replace by only keeping onConfigure
configure?(bv: BpmnVisualization): void;
}
Describe alternatives you've considered
- Using only
configure and not adding onDispose, but this leaves plugins without a cleanup mechanism.
- Naming the method
dispose(), but this can be confusing because the core object already has its own dispose().
onDispose makes it clear that it is a lifecycle hook.
Additional context
This hook will help plugin authors properly clean up:
- DOM or graph event listeners
- timers or intervals
- references to the
BpmnVisualization instance
- cached data or internal state
It also aligns plugin lifecycle management with the new disposal capabilities introduced in the core library.
Is your feature request related to a problem? Please describe.
Plugins in
bpmn-visualization-addonscan register event listeners, allocate objects, keep internal references, or start timers.Since the core library now provides a
dispose()method onBpmnVisualization(see process-analytics/bpmn-visualization-js#3415), the core instance can clean up resources, but plugins still cannot.This may create memory leaks in long-running applications or SPA environments.
Describe the solution you'd like
Add a new plugin lifecycle hook to let plugins release their resources when the underlying
BpmnVisualizationis disposed.Proposed changes:
onDispose(): voidon pluginsonConfigure(bv)hook for consistency (asonDispose), while keepingconfigure(bv)for backward compatibilityplugin.onDispose?.()bpmnVisualization.dispose()Example API:
Describe alternatives you've considered
configureand not addingonDispose, but this leaves plugins without a cleanup mechanism.dispose(), but this can be confusing because the core object already has its owndispose().onDisposemakes it clear that it is a lifecycle hook.Additional context
This hook will help plugin authors properly clean up:
BpmnVisualizationinstanceIt also aligns plugin lifecycle management with the new disposal capabilities introduced in the core library.