Jump to another example:
Basics
Store
Composables
Events
Forms
Events
Events Showcase: dispatchSelf()
Emit an event that is handled only by the same component instance.
How it works
dispatchSelf()
delivers events only to the same component instance. Useful for internal flows
where you do not want other components to react.
Self events handled
0
Last reason
No refresh yet
dispatchSelf() reaches only this component instance.
app/LiVue/EventSelfDemo.php
public function triggerServerSelf(): void
{
$this->dispatchSelf('self-refresh', [
'reason' => 'triggered from PHP',
]);
}
resources/views/livue/event-self-demo.blade.php
<button @click="livue.dispatchSelf('self-refresh', { reason: 'triggered from JS' })">
JS dispatchSelf
</button>