Open J87NL opened 1 year ago
This happens because as you navigate around the app the Echo callbacks get re-registered. I don't know how to fix it in Splade, but this might help someone who does.
I had a similar issue on an inertia repo, where I had created a Vue composable useOnEvent that was getting re-registered because of where it was called (I think it was in a layout component or something like that, I can't remember exactly).
If you console.log window.Echo, check the event callbacks, then navigate around and check again, you'll see it ticks up. Like here, I have 3 callbacks for each event, where there should only be 1.
Description:
Initially, after a hard refresh, when a new event is broadcasted the notification is shown once, as expected. But when I navigate within my Splade app (with
<Link ...>
's) and a event is broadcasted, it shows up multiple times:Posted all relevant code below. Followed documentation as described at https://splade.dev/docs/x-event#Toast%20on%20event In the Pusher Dashboard the event exists only once. I hope someone knows a possible solution for this!
Steps To Reproduce Issue:
Installed with composer:
Installed with NPM:
resources/views/layouts/app.blade.php:
In config/app.php I uncommented:
routes/channels.php:
app/Observers/ReactionObserver.php:
app/Events/AdminUpdate.php: