I used a custom directive to implement this, but essentially:
<div wire:new-like="loadLikes">
</div>
The new-like
event name will listen for any NewLike
events fired on the server (needs to be kebab cased since HTML attributes aren't case sensitive), i.e. event(new NewLike)
will run the action / evaluate the expression. In this case, when the NewLike
event is fired on the server, it will call the loadLikes
method on the component.
An example use case might be on a dashboard, where a scheduled command that runs every minute fires an event at the end of each run, but the event is fired conditionally, so it would make more sense than polling every minute, or sooner.