Reputation: 11
This is a livechat web app, I need to "refresh" when sending a message, poll works well when using now() outside the foreach (to comprobate that works), but inside the foreach the content and now() does nothing!! I need to refresh the browser to see the changes (the new message) and I dont know how to fix it...
I tried all in web tutorials and replicate it to, nothing works for me.
Upvotes: 1
Views: 1066
Reputation: 1182
You can instruct Livewire to run a certain function that the polling will call. Make sure that in that function your do a ->fresh() on the data you want to refresh.
Example:
<div wire:poll="updateMessages">
@foreach($userMessages as $userMessage)
...loop here...
@endforeach
</div>
public Collection $messages;
function updateMessages()
{
$this->messages->fresh();
}
Upvotes: 2