4 ms·
That's because this example is an anti-pattern, the swap should be local [1], the button changes itself (to an orange arrow, to disable itself, etc) and the not
by luxcem 3y ago
That's because this example is an anti-pattern, the swap should be local [1], the button changes itself (to an orange arrow, to disable itself, etc) and the notification tag (#notification-bar) should be responsible of its own behavior.
An idea could be that the notification bar is polling a notification endpoint every Xsec or on a specific event [2], or if you want to be fancy with WebSockets [3]
[1] They actually talk about this: https://htmx.org/essays/locality-of-behaviour/ https://htmx.org/essays/locality-of-behaviour/
[2] for example afterRequest or afterSwap : https://htmx.org/events/#htmx:afterRequest https://htmx.org/events/#htmx:afterRequest
[3] https://htmx.org/extensions/web-sockets/ https://htmx.org/extensions/web-sockets/
- jhp123 3y agoThis doesn't help. Now the implementation depends on another component correctly reading some global state, an undeclared dependency. If I'm reading the upvote button I have no idea that it uses a notification-bar. If I'm reading the notification-bar I have no idea what it's for or who uses it.