Description
First thing first, I'm so happy to see this project! It's a huge deal for Stimulus and Symfony!! 👍
Under this title, I mean multiple things.
- Using disconnect callback
I think all controllers should use the disconnect callback to destroy instances. Like the Chart one.
If I dynamically remove the node from the DOM, the chart instance will remain loaded.
connect() {
this.chart = new Chart(this.element.getContext('2d'), payload);
}
disconnect () {
this.chart.destroy()
this.chart = undefined
}
- Using data maps
Stimulus has a pretty handy API to deal with data: https://stimulusjs.org/reference/data-maps
It's cool because it's name-spaced by default, so it "forces" developer to use it in a more generic way. And it has methods to access datas.
I see lots of this.element.getAttribute('key')
but they are not using data-maps
- Improve inheritence
All controllers dispatch a custom event "extends" controllers in a some way.
I think it would be more consistent to allow developers to extends these controllers like here with instance variables and so on instead of using custom event. Because sometime, it's useful to override the behavior.
Thanks a lot for this project!