Automatically updating a resource field
Hi. I have a resource let's call it HostResource and this resource is based on a Host model that has a status.
Now I would like to update the field of the single status entries for each host from the table even if I change it from the DB. I solved the problem with a polling, taking advantage of the fact that all the filament pages are Livewire components.
However, I wanted to understand if I can use Livewire events. I deduce that in any case the browser is forced to poll to update the modified value, but I'd like to understand if it is possible to use events in this case, I think and how.
also in case of events, should I add the dispatch in the mount of the ListHost and then the method that modifies the model field and the changes would be automatically reflected in the table?
I considered polling the entire table, but I solved it by polling the single field, but if it could be avoided it would be better.
Any idea?
1 Reply
It’s still just livewire. There’s no reason you can’t dispatch an event then refresh the component. Just need to make sure the listener is registered on the page and not on the resource. The pages are the livewire components, not the resource.