by masfoobar · 4mo ago · 0 comments
They were making a big deal with this change. In the end the change is rather minimal. The outcome is reduced javascript code and more server side html templates. Pretty much most of the code is now handled on the server side. Just organise the html templates!
Pseudo example
Instead of :-
<code>
// returning as Json
[Get]
Response GetUser(int id) {
var user = getUser(id);
return ToJson(user);
}</code>
You are just doing :-
<code>
// returning as HTML
[Get]
Response GetUser(int id) {
var user = getUser(id);
return View("som-user-template", user);
}</code>
I don't know what 'hooks' you need, but whatever they are doing you can move them over to returning/updating section of html on the screen with htmx.
For example, on button click to GET html. Again, you can specify what you want to do with the returned html with attributes such as hx-swap
Unless I am misunderstanding, of course.
I do remember triggers/hooks with things like Angular and Knockout. I don't miss this method of web development.
I recommend starting small and working up with htmx. Their examples section on the official website is pretty good.