r/javascript • u/Forward_Dark_7305 • Aug 17 '26
AskJS [AskJS] Signal/Effect vs Event Handler
I’m working in a VanillaJS repository (plugin type code for an existing project that I do not own) where I’ve written a signal implementation.
Today I was working on a tooltip like implementation and I found myself wondering how far to go with the signal/effect ecosystem vs running the “core” logic in the event handler.
The implementation detects the `<tr>` that the user has hovered and assigns that row to the “current row” signal. A computed signal identifies an IP address from the current row. An effect loads Whois metadata from the IP and assigns it to a `<div>`, and another effect shows that `<div popover>` from the parent `<tr>`.
The question I have is when in VanillaJS how would you decide when to use signals and effects vs writing the side effect directly in the event handler? In my case I find either to be equally readable, though I have less local variables to deal with when using signal/effect. Looking for reasons your might pick one over the other.
View all comments
Show parent comment
1
u/Forward_Dark_7305 Aug 18 '26
Because this is a plugin for a system I don’t otherwise control, I can’t modify the table ahead of time (it is SSR’d, all I can do is add a JS script to the page) so I am left with using JS to add a column or popover client-side post-render.
Since the table is >200 rows, thinking of async, debounce and all that, isn’t that incentive FOR using signals and effects? I’m a decent enough programmer that I have handled each of the points you mention - and I would whether I was using signals or event handlers. I think it makes an easier logical graph from “here’s a row” to “here’s the current row” to “here’s the behavior for the current row”, but it is less code to drop it all into the event handler - just then that chain U mentioned is more like “here’s a row”, “here’s a behavior of the row” (making debounce + stopping stale fetches less obvious) in my mind.