F
Filamentβ€’16mo ago
Oussama

Refreshing table records after a page action

Currently using this implementation, which works technically but the notification animation isn't smooth, probably due to some re-rendering of the whole ManagesPodcastEpisodes::class, is there a way to only refresh records and not the whole thing?
// ManagesPodcastEpisodes::class
protected $listeners = [
'cache-cleared' => '$refresh',
];

protected function getHeaderActions(): array
{
return [
Action::make('forceRefresh')
->label('Force Refresh')
->action(function (): void {
Cache::forget(PodcastEpisode::CACHE_KEY);
// Sushi will handle the rest

Notification::make()
->success()
->title('Podcast episodes refreshed.')
->send();

$this->dispatch('cache-cleared');
}),
];
}
// ManagesPodcastEpisodes::class
protected $listeners = [
'cache-cleared' => '$refresh',
];

protected function getHeaderActions(): array
{
return [
Action::make('forceRefresh')
->label('Force Refresh')
->action(function (): void {
Cache::forget(PodcastEpisode::CACHE_KEY);
// Sushi will handle the rest

Notification::make()
->success()
->title('Podcast episodes refreshed.')
->send();

$this->dispatch('cache-cleared');
}),
];
}
2 Replies
Dennis Koch
Dennis Kochβ€’16mo ago
Not really. That's how Livewire works.
Oussama
OussamaOPβ€’16mo ago
Alright thanks, I suppose it's good enough πŸ˜„
Want results from more Discord servers?
Add your server