0๐
โ
I think the problem is more difficult as you think.
First: When you mount the component, this code runs window.Echo.channel()
but only one time. When you change the Id variable, this code wont register again the channel listening.
Second: The console writes the modified ID variable because the log writer uses that refered variable, what is changed. (I hope you understand. ๐ )
Solution: you should move the ID variable changing logic to the parent component, and re-render / re-mount this component every id change event.
(Or ugly way: you should make a watch method on id, and whenever it changes, reregister the channel listening. But self re-mountning not a good way..)
I Hope it helps! ๐
Source:stackexchange.com