Hi,
I'm new at front-end. lately I start learning Vue and Inertia for build my front-end. I started by a simple blog.
What I want is:
When a new comment added by users then a Number shows off the front of comments section in admin panel. without I reload the admin panel.
First I think one solution is use Inertia.reload({ only: ['countOfNewComments'] }) every 5 seconds but now I think it's kinda stupid.
I read all Inertia docs and seen some tutorial in Youtube and now I can build a CRUD with table filtering and all these regular stuff but nowhere I found this simple notif thing in the examples.
No! I don't want you to write code for me :) I just need a clue. I really would be thankful if you guide me and tell me what should I do in general or even if you know an example, give me the link of it please.
Thank you.
Would you explain more your second idea please?
What you mean about "channels"? which channels exactly?
And when I listen something at the back-end, how I tell the the Inertia at front-end to apply it?
What you are describing is called polling. That is indeed one solution. I would do it with plain javascript (Fetch or axios) instead of involving Inertia.
Another solution is to use websockets. This allows the server to "push" the message to the browser. Laravel has a built in implementation for this using Pusher (if you want it to be free, you can self-host Soketi)
https://laravel.com/docs/9.x/broadcasting#main-content
@AlexDFCH Personally I use broadcasting for a chat system and I self host soketi. But you can start with pusher.com (I think they have a free tier). They are compatible so you can switch later if you want :)
@Sinnbeck Maby this question is funny, but I'm wondering why we need another thing (Pusher or Soketi) for doing something simple like sending just some data between back-end and front-end?
What is here that I don't understand? How I should have a better view about this?
(Honestly, sometimes I think I'm too old for this job. you open a door and you see a room with 5 other closed doors and you feel confused)
@AlexDFCH Happy to help. You can test out both version and see what you like. Maybe the inertia version works perfectly for you and then just go with that :)