Dispatch Event on AfterStateUpdated()
Hello,
Does anyone know how to dispatch event for example to update-counter within main resource? Like we have $this->dispatch in Livewire components and in List,Edit filament classes, I need kind-a same thing but within main resource..
6 Replies
I'm assuming, since filament is basically fancy livewire components you probably could use $this->dispatch()?
Sadly no, it is within static method so $this-> wont work
Just wondered if anyone had an solution?
You could try to pass the livewire instance as a parameter?
Then you could use that to call ->dispatch()
Maybe not the prettiest solution, but maybe it works
Thanks mate alot! You gave me perfect direction, i passed livewire insatnce as paramter and than i created pub function in List resource whic has access to $this->dispatch() that did the trick
ContactFormResource
in ListContactForm
Cool it works!
Maybe you could even do $livewire->dispatch('update-counter') directly in the afterStateUpdated, saves some code. Unless you use that method at other spots.
Happy coding! Don't forget to set this thread as solved :D
Tried with $livewire->dispatch('update-counter') but it looks for dispatch() functon on List class hence why i did that extra code 🙂