Functional API Doesn't Support Interaction to Livewire `$refresh` Magic Action
devajmeireles opened this issue · comments
Volt Version
1.6.3
Laravel Version
11.4.0
PHP Version
8.3.6
Database Driver & Version
N/A
Description
While Livewire offers two ways to perform $refresh
operation:
In an original Livewire component
Using #[On]
on top of the class, implemented here: livewire/livewire#7667
#[On('refresh::create-post')]
class CreatePost extends Component
{
// ...
}
Using the old approach $listeners
:
class CreatePost extends Component
{
protected $listeners = [
'refresh::create-post' => '$refresh',
];
}
In Volt's functional API style, we have no way of doing this. The docs doesn't mention anything about this. Thinking it would possibly be ready to use, but out of the docs, I tried:
on(['refresh::create-post' => fn () => '$refresh']);
on(['refresh::create-post' => '$refresh']);
None of this worked.
Steps To Reproduce
- Create a Volt component using the Functional API
- Try to dispatch an event that requires the Livewire
$refresh
magic action
Thanks. We'd appreciate a PR to help make this possible.
Thanks. We'd appreciate a PR to help make this possible.
Sure thing! I can try that, but don't you think it's better to keep the issue open with the help wanted label?