DEV Community

Stimulus JS - Accessing an action in another controller

Jude on June 19, 2023

If you've used Stimulus before, you should know that controllers are scoped. This can be useful, but you might come across a case where we want to ...
Collapse
 
haroldmeza profile image
haroldmeza

Nice tip, i used the communication between controllers through dispatch, but this feature has a weird inconvenient, you lost this context when you wanna communicate with other component, so you can't access the real context in the receiver component, but using window.dispatchEvent, you don't lose this context in the reciever component, thanks, you make my day

Collapse
 
katekostina profile image
Kate Kostina

Thanks, that was helpful!