F
Filament4w ago
taz

Lazy load a custom column in a table

I display a Model in a table and all of its columns are model attributes that are stored in the DB so the table loads instantly. Now I need to display a computed attribute that requires an api call to an external service that takes 2s approxiamtively. Id like to lazy load only the column displaying that attribute. I was thinking doing like this
use Filament\Tables\Columns\Column;
use Livewire\Attributes\Lazy;

#[Lazy]
class CustomStatus extends Column
{
public $longAttributeToCompute;

public function mount()
{
$this->longAttributeToCompute = ExternalService::longApiCall($this->getRecord());
}
protected string $view = 'filament.tables.columns.CustomStatus';
}
use Filament\Tables\Columns\Column;
use Livewire\Attributes\Lazy;

#[Lazy]
class CustomStatus extends Column
{
public $longAttributeToCompute;

public function mount()
{
$this->longAttributeToCompute = ExternalService::longApiCall($this->getRecord());
}
protected string $view = 'filament.tables.columns.CustomStatus';
}
But is Livewire Filament\Tables\Columns\Column is that a Livewire component ? Or its possible to make CustomStatus a Livewire component ?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server