Hey I was wondering what was the best way to integrate stimulus with websockets
What I am currently doing is that I have a websocket with some javascript updating the controller html attribute and I have the stimulus controller refreshing with a timer.
Here are my questions.
-
I see there are onlick, onsubmit handlers, are there other handlers ? (can you add some ? typically when my websocket receives new data I would like to trigger an event to refresh the element)
-
Is there a way to re-initialize the element ? or maybe deconnect it and reconnect it. Just thinking out loud here.
(detail, I’m using phoenix with elixir, but I think this is applicable for any other backend framework that supports websockets)