Login
You're viewing the ruby.social public feed.
  • Jan 20, 2024, 1:28 PM

    I think what I really like about htmx is that it presents a clear separation of concerns to the developer.

    I remember when web applications were CGI programs and then they moved to web applications. Zope and Turbogears were my first real environments for this.

    When I first learned about single page web applications it was with Backbone.js, and then later React.

    I thought these were the right approach because they separated concerns, but....

    1/

    #web #htmx #programming

    💬 2🔄 0⭐ 0

Replies

  • Jan 20, 2024, 2:12 PM

    @emacsen FWIW I use react but my mental metaphor isn't "single page web application", it is "web site".

    I lean heavily on the react router for navigation and will reload to the same "web page" with the state restored if I press F5 on a page.

    💬 1🔄 0⭐ 0
  • 💬 1🔄 0⭐ 0
  • Jan 20, 2024, 4:00 PM

    @emacsen Um... if you mean "web site" it's that I think about the application as an old style interlinked collection of HTML pages and/or CGI scripts so I use "hyperlinks" that works internally with the react router (just routing inside the browser), but also changes the URL so that you get a new location if you should happen to reload.

    The app has to be able to restore on reload.

    The oldalbum application I mentioned yesterday is like this: oldalbum.bang.priv.no/moto/vfr (my trusty old VFR in 1996)

    💬 2🔄 1⭐ 0
  • Jan 20, 2024, 7:30 PM

    @emacsen A little more detail on what I'm doing.

    Firstly: I'm still using redux (this makes many shake their head and go away).

    My reasoning around still using redux is here: steinar.bang.priv.no/2022/06/2

    And I'm using redux in combination with sagas and the react-router.

    This are important building blocks in restoring the state when reloading on a particular path.

    More in the next post (I need to provide a new URL)

    💬 0🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • Jan 20, 2024, 7:42 PM

    @emacsen Every time a path is navigated to, a LOCATION_CHANGE redux action is emitted (by redux-first-history) and the locationSaga can listen to it and take action, such as e.g. firing off new redux actions to start downloading data needed for that path.
    github.com/steinarb/oldalbum/b

    And when the application is reloaded, LOCATION_CHANGE for the reload path is one of the first actions emitted, which means that a reload on a path can take the same action as navigating to a path.

    More in next toot

    💬 0🔄 0⭐ 0
  • Jan 20, 2024, 7:54 PM

    @emacsen I used to use class components with componentDidMount() to trigger the load of data needed for the component.

    I've replaced that with locationSaga and that was conceptually much simpler (to me) than going the hook with local state and useEffect() way (see the blog post) earlier in this thread.

    💬 0🔄 0⭐ 0
  • Jan 20, 2024, 8:18 PM

    @steinarb

    As I understand it, React was built because there were so many independent activities on a FB page, from each story, to chat, to roster, to third party apps.

    Is your use case for React similarly dynamic and complex?

    💬 1🔄 0⭐ 0
  • Jan 20, 2024, 8:22 PM

    @emacsen Nope.

    Here I differ a lot from react's origin.

    My use case is replacing what I used to do with HTML and CGI scripts. Forms and stuff.

    So maybe react is the wrong tool... but it's the tool I know. 🙂

    💬 1🔄 0⭐ 0
  • Jan 20, 2024, 8:24 PM

    @steinarb

    The reason I've been writing about html is that I spent a lot of time learning React, and so much of the web is motivated by Javascript- including the rise of Node, which is at least partially motivated because people didn't want to switch between languages.

    The problem though is that you end up with two sets of state- that on the server and that on the client. If you have a lot going on on the server, or you are focused on offline first, that's great, but that's not...

    1/

    💬 2🔄 0⭐ 0
  • Jan 20, 2024, 8:26 PM

    @steinarb

    But that's not what most people use it for. They're using a lot of "framework" for what is really just serving HTML with a little interactivity.

    I was convinced too that only serving Javascript was somehow going to improve security, but in reality the server needs to serve what the client needs, which means that endpoints are either JSON versions of client endpoint, or the client does a lot of work.

    2/

    💬 1🔄 0⭐ 0