Orvalo
Orvalo
FFilament
Created by Orvalo on 3/14/2024 in #❓┊help
Events on widget from custom page
Hey, Is it possible to dispatch an event from a custom page to a widget?
// /app/Livewire/CustomPage.php

public function getHeaderWidgets(): array
{
return [
ExampleOverview::make([
'foo' => $this->foo ?? [],
])
];
}

public function refresh(): void {
$this->foo[] = 0 // New data chart
$this->dispatch('update-foo');
}
// /app/Livewire/CustomPage.php

public function getHeaderWidgets(): array
{
return [
ExampleOverview::make([
'foo' => $this->foo ?? [],
])
];
}

public function refresh(): void {
$this->foo[] = 0 // New data chart
$this->dispatch('update-foo');
}
//app/Livewire/ExampleOverview.php

class ExampleOverview extends BaseWidget
{

public array $foo = [];

#[On('update-foo')]
protected function getStats(): array
{
return [
Stat::make('','')
->chart($this->foo)
];
}
}
//app/Livewire/ExampleOverview.php

class ExampleOverview extends BaseWidget
{

public array $foo = [];

#[On('update-foo')]
protected function getStats(): array
{
return [
Stat::make('','')
->chart($this->foo)
];
}
}
1 replies