Episode Details

Back to Episodes
Why I Believe In Livewire

Why I Believe In Livewire

Episode 17 Published 6 years, 9 months ago
Description

All right, so you're probably expecting my answer to this why I believe in Live Wire to be kind of like the last episode pretty soft broad vague inspirational. I don't know but. It's actually not it's pretty concrete. I believe in Live Wire because of one moment three years ago. I was reading a blog post by th where he demonstrates.

Why? Why are we just a Jackson Json? Why not Ajax HTML already rendered on the back end and then just swap it into the page and you know, and he called it server render JavaScript and the rails Community is kind of all about this I discovered it and it hit me like a ton of bricks and I went whoa.

And I was just immediately enamored with the idea. I used it in a project and it worked exactly as well as I thought it would and I was able to use blade but still, you know, get all the benefits of you know deferring loading a jack seeing this stuff, you know, whatever like making Dynamic pages that don't reload but still just using blade for everything and I was enamored with it.

And from that on like that that has been a known good to me. Like there's so little downside to that strategy. It's crazy. And that's why you know, I'm sure I've talked about this a hundred times. You've seen this in every talk that I've given whatever like GitHub you open up xhr Tab and devtools get up devtools and you just see Ajax request flying off the handle and almost none of them are returning Json.

They're all returning rendered HTML these P Jax to do this. And so why is this the reason that I believe in live wires the reason because that's what live where is it's built on this concept Live Wire is age axing HTML. There's a bunch of extra stuff that makes it super duper seamless. So you don't have to before you would have to do the wiring yourself.

You have to trigger the Ajax request and you have to swap it into the page. Livewire hand gives you a nice API for when to trigger. The request to get new Json or sorry new HTML and it's smarter than just just wiping out the HTML with the new HTML. It does the Dom dipping stuff like we've talked about but that's it.

That's what it is at its core like at its core. That's what it is. So if that's the problem live wires solution. And there's a lot of other features in Livewire a lot of extra things a lot of huge potential for ways. It can be used really clever things. Like we've talked about the prefetch stuff and dirty detection and loading States and all sorts of stuff that it grants you that's really nice and whatever huge potential.

But at the end of the day strip all those things away and live we're still useful for this use case and it's a pretty big one. So this is why I believe in live where I believe in live where in general but but I got to be honest. It's definitely, you know times that I doubt certain features or doubt certain use cases and a pretty vocal about him.

I mean, I the whole counter examples just. BS like I wouldn't use live wire for a counter, I feel kind of weird every time I use Livewire to just like show or hide something on a click, you know, I feel like whole Ajax request for a freaking toggle. Like I should be using JavaScript for that. Like I feel that way, you know, so in that way the live where water is a little bit muddy, but but forget about that stuff like let's talk about.

Let's talk about swapping and ajax deferred loading, you know, like Auto searching, you know form like a story table stored in real-time validation realtor auto-saving forms. Like these are all things that. That live wire is not adding anything like you're already submitting Ajax request. You're just sending Json doing the templating on the front end and by doing that you're dealing with the templating in a totally separate language that's not easily testable.

And isn't it is totally separated from your front end. So you need like double the routes and double the code. Basically we're live. We're just a

Listen Now

Love PodBriefly?

If you like Podbriefly.com, please consider donating to support the ongoing development.

Support Us