23m/livewire-async
最新稳定版本:0.2
Composer 安装命令:
composer require 23m/livewire-async
包简介
Extending the Laravel Livewire's component to load asynchronous
README 文档
README
This package is not maintained anymore because Livewire 3.0 is out. It has a built-in solution for async loading. See Lazy Loading in the official documentation.
Livewire Async
We totally ❤️ Livewire by Caleb Porzio.
It renders the components on first page load. For a good reason. But if your component uses an API, you might not want to wait for it. For Livewire this is called Defer Loading and it is of course documented well.
However, if you build multiple components with this behaviour, it feels kind of repeating yourself. This is where this package comes in. It shows a loading animation on first page load and delivers the content asynchronously.
Install
You just want to run
$ composer require 23m/livewire-async
That's it.
Create component
Since this package does not come with a make command (yet), you can use Livewire's command.
$ php artisan livewire:make api.heroes
After opening your component in app/Http/Livewire/Api/Heroes, there are only small changes needed:
- Your class should extend
TTM\LivewireAsync\AsyncComponentinstead ofLivewire\Component - Rename the method
rendertorenderAsync
Your component should look something like this:
use TTM\LivewireAsync\AsyncComponent; class Customer extends AsyncComponent { public function renderAsync() { $heroes = Http::get('example.com/heroes')->json(); return view('livewire.api.heroes', compact('heroes')); } }
Create your view as you are used to.
And here we go:
统计信息
- 总下载量: 7.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-12