For example, to access
Stimulus Targets, we use below property
this.[name]Target this.[name]Targets this.has[Name]Target
- We should add suffix to the target name
- We should capitalize the first letter if to access
I do not like this pattern and want to improve it
What about this way?
this.target.[name] this.targets.[name] this.hasTarget.[name]
I do not need to change the case of the Targets, and the API seems more cleaner.
I decide to build simple package to solve the problem and now the code is open sourced on https://github.com/AccordBox/stimulus-magic , and here is the npm package stimulus-magic - npm
Any feedback is welcome.