[Feature Request]: Livewire Events Click Through
Feature Description
Would be great to have a click through functionality for Livewire events:
Livewire:
public function livewireFunction() {
$this->dispatch('event-name');
}
Blade:
@script
<script>
$wire.on('event-name', () => {
// do something
})
// or
Livewire.on('event-name', () => {
// do something
})
</script>
@endscript
We thought about completing them, but where should Click through go? To the on() call?
We thought about completing them, but where should Click through go? To the
on()call?
Yes, I believe so.
So when event is dispatched from Livewire component with $this->dispatch('event-name');, I would expect all the following events to match on all Livewire components:
document.addEventListener('event-name', function() {});
$wire.on('event-name', () => {})
Livewire.on('event-name', () => {})
When event is dispatched from JS with Livewire.on('event-name') or $wire.dispatch('event-name') should go to all Livewire components with #[On('event-name')]
If there are multiple it should have the same dropdown as you do next to the Model name.
There are also: dispatchTo() and dispatchSelf()