Level 1
I mean I can alternatively just check the if($currentPath != $lastPath) from the render, since it's just a server side code.
I just am confused why it isn't dispatching the event...
Livewire isn't dispatching another wire dispatch event. It was perfectly working a while back. I don't understand why it has suddenly stopped working.
Here's the code:
public function getListeners()
{
return [
"path-changed" => 'updateCurrentPath',
];
}
#[On('refresh-last-active')]
public function refreshLastActive()
{
$visitor=collect(json_decode($this->visitorCollection));
// dd($visitor);
VisitorLastActiveUpdate::dispatch($visitor);
}
#[On('path-changed')]
public function updateCurrentPath()
{
dd('yo'); //dd for checking if it's triggering, which it isn't
$visitor=collect(json_decode($this->visitorCollection));
$currentPath=$this->currentPath;
$some=VisitorCurrentPathUpdate::dispatch($visitor, $currentPath);
}
And the blade of the component is this:
@script
<script>
$wire.on('message-created', () => {
playSound("{!! asset('/source/message-tone.mp3') !!}");
});
function refreshEventDispatchingForLastActiveUpdate() {
$wire.dispatch('refresh-last-active'); // Working
}
setInterval(refreshEventDispatchingForLastActiveUpdate, 5000);
Echo.private('chat.{!! json_encode($chat->id) !!}')
.listen('SendMessage', (e) => {
console.table(e);
playSound("{!! asset('/source/message-tone.mp3') !!}");
});
</script>
@endscript
@if($currentPath != $lastPath)
@script
<script>
$wire.dispatch('path-changed'); //Not working but used to while ago.
</script>
@end
@endif
I've placed comments to the code too. Did someone else have this issue? Technically it's not dispatching multiple wire events. (Note: already turned off the interval function to see but not it)
Please or to participate in this conversation.