I have found this solution to refresh automatically the list.
<script>
Echo.join('my-channel')
.here((users) => {
Livewire.emit('UsersList', users);
})
.joining((user) => {
Livewire.emit('UserJoining', user);
})
.leaving((user) => {
Livewire.emit('UserLeaving', user);
})
.error((error) => {
console.error(error);
});
</script>
And in my component.
protected $listeners = [
//'echo:my-channel,here' => 'notifyMessageSent',
'UsersList' => 'setUsersList',
'UserJoining' => 'addUser',
'UserLeaving' => 'removeUser',
];
But how to do (and is it only possible to do) the same with this listener in Livewire ? For me it doesn't work the event is not detected.
protected $listeners = ['echo:my-channel,MessageSent' => 'notifyNewMessage'];