Skip to content

Latest commit

 

History

History
27 lines (23 loc) · 440 Bytes

event-listeners-over-polling.md

File metadata and controls

27 lines (23 loc) · 440 Bytes

☔ Prefer to use event listeners over polling

❌ Bad:

<div wire:poll>
    User Content
</div>

✔️ Good:

Define the listener in the component using On attribute:

class Dashboard extends Component
{
    #[On('post-created')] 
    public function updatePostList($title)
    {
        // ...
    }
}

Dispatch the event in every other component:

$this->dispatch('post-created');