Josh Hanley - Building a maintainable Livewire application - Laracon AU 2023
HTML-код
- Опубликовано: 11 июл 2024
- Join Josh Hanley as he sails through ways to build a maintainable Livewire application while cruising Australia's east coast. Dive into topics like page components, naming conventions, and effective organisation.
00:00 Components
02:08 Page components
03:32 Invokable components
04:21 Naming conventions
05:25 Organising components
06:47 Computed properties
10:19 Cached properties
10:51 Component structure
15:25 Form objects
17:24 Action classes Наука
Is there more content like this?
This is by far the hardest information to get to as someone that has progressed past the basics.
I don't have anything at this stage, but would be open to putting more information out there. Do you have anything in particular you would like to learn about?
Great tips!
Biggest benefit imo of action classes (or any other business logic layer) is we can now reuse that logic in other parts of the system (API endpoints, Jobs, Commands, etc.). It's no longer tied down to the Livewire component itself.
Thanks!
Yep exactly! I love using them personally😁
very insightful thanks mate!
No worries! 🙂
What I do instead of #Computed is just do the fetching in render() and pass it to view(). Is this a bad idea?
Nope, that works fine. It's more of a traditional Laravel way to do things though, where as computed properties and public properties are more of a Livewire way to get data to the view as Livewire handles it for you.
I personally don't like doing it that way, as I like to keep my render method clean.
Using computed properties has the added bonus of memoisation and caching, plus they are easier to unit test than data called in the render method.
@@joshuahanley32 I appreciate your insights! Thanks for taking the time to reply.
I will keep those points in mind 👍🏻👍🏻
@@joshuahanley32 I've experimented a bit with #[Computed] and I love it. Thanks! Slowly migrating components as I am working on them. Looks much cleaner.