I want to ask if the information as outlined in the following tutorial is still valid for latest Phoenix versions, or is there any new methods to notify about model changes by channels:
I want simply notify the front-end and instruct it to reload the page if new records were created.
Thank you.
I should have mentioned that I do complete separation between back-end (Phoenix) and the front-end (JS driven). So, in other words, how to monitor model changes and notify the JS based front-end about those changes? To put the notifier method (broadcasting the change to the clients) inside the create/update/delete methods?
It does require you to implement graphql in your frontend though.
Which is not a bad thing as graphql fits your needs perfectly.
Also I can fully recommend Absinthe, it’s awesome.
For my current and future projects I use only PostreSQL. You mean to make PostgreSQL notify Phoenix, which in turn notifies the clients via channel messages?
The problem is probably not knowing when inserts and so on are executed, because you are probably using Ecto.Repo.insert/2 in some module that handles these things.
Probably the problem lies in the plumbing that connects the frontend to the backend.
This is where Absinthe/GraphQL comes in.
Yes, this is still relevant. The code is a little dated versus some new stuff, but the ideas are the same. There’s no need to use LiveView or Absinthe, you can just use Channels. The Real-Time Phoenix book goes over this with theory, examples, and real-world example.