Livewire: new screencasts, an Alpine plugin, a helper method, tips, and updates...
- Get link
- X
- Other Apps
| Heyy! Got a big pile of stuff for your eye balls this morning, so put the tea on, grab your blue light glasses, and let's goooo... 🚀 New screencast drop: Drag SortingA month ago I made a Trello clone in Livewire (demo tweet here). While building it, I learned it's still not super easy to do that sort of thing in Livewire. So I made a made a course! I ended up building and scrapping this series multiple times until I got it JUST right. It's been way too long of a road, but I'm proud of the finished product. Even if you don't care about sorting, I bet you'll learn a thing or two along the way. Here she is: Go binge "Drag Sorting" here → Part of the sob story is trashing everything and building an official Alpine plugin to handle most of the hard parts instead. Check out the official "Sort" plugin → ⚡ New Livewire version: 3.4.11Heads up, you should upgrade your apps to the latest version of Livewire: 3.4.11, so that you have everything I'm about to mention in this email! Check out the release notes → 🦷 New method: pull()While I was writing the sorting series I had an idea: a pull() method that both returns and resets a Livewire property in one swoop: Before pull(): After pull(): 🐕 Testing lazy componentsTiny little addition, but one of our Livewire Partners recently brought to my attention that there's really no way to unit test a lazy component in Livewire. (It will only render the placeholder during the test) Livewire version 3.4.11 now ships with ->withoutLazyLoading() 🩳 Nested attribute shorthandThis one's not new and you probably already use it, but in case you don't, here's one of my favorite little additions to Livewire version 3. Being able to use the Blade attribute shorthand instead of duplicating a variable name inline: ✂️ Keep list methods in list componentsYou ever have a Livewire component that loops through a list of Eloquent models and displays them each inside a nested component like this? What's that? All the dang time? Well, hot tip: keep "list manipulation" methods like "add" and "delete" inside the list component, and keep "item manipulation" methods inside the nested item components: If you need an item to delete itself? no problem, call delete() on the parent from the child and pass in the id: What's that? You forget $parent is a thing too? I know. Super duper powerful. But for real, this is a golden pattern and will make your apps better when you use it. 🎲 Lottery goodnessThis is a fun one. If there's any kind of "periodic work" you need to do in your app, before reaching for a scheduled/cron job, you might be able to get away with this secret little utility available in Laravel: Illuminate\Support\Lottery I needed this in the sorting series to periodically ensure the positions are correct in the database every once in a while (they can get out of whack for...reasons). Fun fact: Livewire uses this under the hood to clean up old session files in your app. Every 1 in 50 requests I think gets taxed with doing the cleanup. 🇲🇽 MexicoooMade it this far? Here are a couple soft/life/livewireish updates. First, my wonderfully awesome wife Hannah and I just got back from our second "babymoon" for the upcoming little lad. We escaped to sunny Mexico while our parents stayed home and tickled our baby boy #1 for the week. Six days. I didn't open Twitter once. I didn't even bring my laptop. Just quality time with my wife in a beautiful place. Felt pretty great. I way under-valued relaxation before having a kid, and now I CRAVE it lol. Grass is green. 🎁 Someone gave me a monitorIn other fun news, a Livewire Partner who shall rename nameless saw me tweeting about buying a mac Studio Display and privately texted me: "Hey, go to the apple store and buy one for yourself, on me." Wut? Who does that? So crazy how generous and kind people are. My current monitor is super old and small and my dev life just got a massive upgrade because someone wanted to support Livewire by supporting me. Thanks someone ❤️ 🎂 Livewire turns fiveSomeone just DM'd me recently telling me: "Hey, you should celebrate, the Livewire repository just turned five." I was actually surprised. Has it really been five years? I left my day job at Tighten in early 2019 with no plan. A few days later I started building Livewire and haven't really done anything else since. Life is funny like that huh. Alright, this email is way too long. As always, if you respond to it, it'll go to my personal inbox and I read every single reply. I respond to *most* of them. I love you all. -Caleb |
- Get link
- X
- Other Apps
Comments
Post a Comment