4 ms·
bang on, especially that last part a bit focus of htmx, alpinejs (and htmx's sister project, https://hyperscript.org https://hyperscript.org) is putting the lo
by recursivedoubts 5y ago
bang on, especially that last part
a bit focus of htmx, alpinejs (and htmx's sister project, https://hyperscript.org https://hyperscript.org) is putting the logic on the element, so you can see exactly what a button, etc. does just by looking at it, and without trawling through ten files of indirection
i am trying to popularize the term Locality of Behavior to describe this design goal:
https://htmx.org/essays/locality-of-behaviour/ https://htmx.org/essays/locality-of-behaviour/
- lhorie 5y agoI'm curious about your thoughts on that locality of behavior idea vs aspects of precision and composability. For example, the argument goes that the behavior of `hx-get` is obvious upon inspection, but the terseness is achieved by omitting the event type (i.e. it's assumed/implied that hx-get runs on click). The quintessential widget where that breaks down is the table w/ checkboxes for batch operations over an arbitrary subset of rows. That's where less DSL-ish frameworks' abstraction via state management tend to shine, since they allow the developer to more precisely specify how disparate checkboxes relate to a bigger picture that may also involve table sorting (both client and server varieties) or nested modal structures or other forms of complexity.
- EugeneOZ 5y agoButton should not have any behavior, it should generate an event. Your app can have one or multiple listeners for this event. This pattern is battle-tested for decades.
- recursivedoubts 5y agoOK, but the response to that event should be localized to the button. https://htmx.org/essays/locality-of-behaviour/ https://htmx.org/essays/locality-of-behaviour/
- JasonCannon 5y agoWhy? Have any reading on this?
- EugeneOZ 5y agoOf course :) Have you tried to find something before asking? https://en.m.wikipedia.org/wiki/Reactive_programming https://en.m.wikipedia.org/wiki/Reactive_programming https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener https://developer.mozilla.org/en-US/docs/Web/API/EventTarget...
- JasonCannon 5y ago1.) Don't be a jackass. 2.) I know what reactive programming is, I make extensive use of RxJS at work. And I obviously know what an event listener is. I was asking why is it wrong to have the button have functionality and only emit events. And I did google that, but nothing from your comment you posted that I googled lead to anything about reactive programming.
- EugeneOZ 5y ago1) You started it :) Your sarcastic tone was ridiculously obvious :) I gave you the links - where is your gratitude? You’ve only brought your sarcasm here. 2) Oh, RxJS is synonymous with reactive programming for you? Lol, keep learning :)