How to Fetch a Turbo Stream
ducktypelabs.com
ducktypelabs.com
If you haven't tried it, you can basically annotate your html with tagged areas, use your normal server-side rendering, and do in-place replacements / edits / updates with your normal server-side rendered pages. It's very railsy, and I mean that in the best way.
I wouldn't use it for the most demanding client-side interactive experiences, but for most use cases, it's close-to-react level interactivity for maybe 10% of the dev time.
One of the things I've found difficult coming back to Rails is how spread out all of the behavior is in so many different files and partials and helpers. While SPAs have a lot of trade-off, organizing related code into components works so much better than any experience I had with server-side MVC, especially when using something like TypeScript and Remix's islands that very effectively isolate even further into logical modules. What little I've done with Hotwire/Turbo made it seem like very basic behavior is even more spread out and even harder to reason about for someone who didn't write it, which seems like it would make maintenance and refactoring in Rails even more time-consuming and perilous than it already is.
I'm really interested in the technology because I hear such glowing reviews of it, but I'm not sure I see it. I'd love to see a non-dogmatic comparison of SPAs vs Rails with Hotwire/Turbo MPA for post-MVP longer-term projects.
I think your complaint is fair but I'm not sure it is a fault with Rails so much as I've rarely seen anyone interested in organizing their Rails code more than the default.
Personally, I think it is really helpful, especially when it's as easy as using modules or having interfaces between modules. If you want feature-based structure, I'm pretty sure you can do it but that'll be a bit more involved. There are some gems out there that support those efforts.
I've found with Stimulus/Hotwire/Turbo that separation of concerns and finely composed partials can help a lot.
1. (This is the current entry point): I have a rails app already, and I’m looking to progressively enhance it with a splash of turbo, responsiveness, magic. 2. (This is where something is missing): I’m building a rails app for the first time, and want to start out with a relatively high level of interactivity using hotwire. The docs don’t really offer much wisdom here, I’ve found, probably because the main adopters have all added this incrementally.
When you’re building from scratch, it’s harder to know which pattern will work best.
If you're willing to jump the hoops of googling everything yourself and figuring out it's intricacies or better yet reading the source then go for it. The official docs are not just lacking they dont even exist.
https://github.com/while1malloc0/hotwire-go-example
if that's the case, there is definitely an opening on the market for such tech.
As someone who's been writing web apps since DHTML days, Livewire/Turbo feels like we've finally reached the future, although with caveats.
This is an extremely trivial bit of JavaScript, but it is made difficult because it is trying to use a JavaScript framework developed by people who hate JavaScript. Do the form validation on the client side to give users instant feedback and then do final validation on the server side where you enforce business rules. These are two different kinds of validation and it's not actually effort saving to try to combine them. If you have good client side validation, you can just be a hard ass on the server side because you know that anyone who gets the server side error is already bypassing client side validation, so they are being naughty to begin with. It makes like easier to keep the validation separate.
Either way, you can just do a quick JSON fetch call on the client side as part of client side validation once customers type the code into the box and then pass it along to the server for the final POST.
If I understood correctly it does. They are handling promo codes outside of stripe.
I feel like you are missing the point of the article
> This is an extremely trivial bit of JavaScript, but it is made difficult because it is trying to use a JavaScript
Yes, it is trivial javascript, and it was trivially solved by a couple of javascript lines