structurizr / java

Structurizr for Java
https://docs.structurizr.com/java
Apache License 2.0
1.02k stars 290 forks source link

Support observing changes (at least to model) #302

Open mwhipple opened 5 months ago

mwhipple commented 5 months ago

Description

Currently scripts/plugins seem to be applied to the current state and therefore need to be run at appropriate time(s), but it could be valuable to define behaviors that should work across time to avoid that sequencing and enable easier reuse (i.e. defining such behavior in a base workspace). For example some basic pseudo code of:

!script kotlin {
  workspace.model.onElementAdded { el ->
    if (el is com.structurizr.model.GroupableElement) el.addTags(el.group)
  }
}

Support for adding would seem helpful since it would presumably work with the DSL but I'm not sure about practical use for observing other types of changes since they would presumably be done programmatically anyway. Adding this on Model seems valuable, I could imagine it being useful on ViewSet (not sure about any others).

Priority

I'm willing to add this feature myself and raise a PR (please confirm approach first)

More information

No response