Extra request when notifications are triggered using $wire vs javascript

Does anyone know why notifications sent using a $wire method:
public function successMessage(): void
{
Notification::make()
->title('Operation Successful')
->success()
->send();
}
public function successMessage(): void
{
Notification::make()
->title('Operation Successful')
->success()
->send();
}
make 1 more backend request compared to notifications triggered via js:
triggerNotification: function() {
new window.FilamentNotification()
.title('Operation Successful')
.success()
.send();
}
triggerNotification: function() {
new window.FilamentNotification()
.title('Operation Successful')
.success()
.send();
}
? If I use <button @click="triggerNotification()"> there are only 2 requests. One when the button is clicked, one when the toast disappears. But if use <button @click="$wire.successMessage()" then 2 requests are made in quick succession when the button is clicked. Meaning a total of 3 requests. Just trying to figure out how things are working under the hood
2 Replies
Patrick Boivin
Patrick Boivin15mo ago
I'm not sure, but I think in the case of $wire.successMessage(), the first request just calls the livewire method, and then the second triggers the notification.
binaryfire
binaryfireOP15mo ago
@Patrick Boivin Ok that makes sense. Cheers
Want results from more Discord servers?
Add your server