Handle_info avoid multiple database inserts

Hi all,

I have a live view LV which is subscribed to a pubsub topic T.
I broadcast messages to T and I handle them in LV with the standard handle_info.

When LV receives a message of the form {:job_done, job_details} it creates a notification about that.

Problem is if I have 3 tabs open I have 3 LV that receive that message and 3 notifications are created.

What can I do to avoid that?

Cheers!

To me it feels like the entity that is responsible to react upon completed jobs and creating notifications should be something else than the LiveView. Maybe some kind of single GenServer that is started along with the application.

Seems sensible, yes. Thank you.

(Sometimes I use the forum for rubberducking, apologizes but working alone is hard…)

2 Likes