shahryarjb
Hi, how can I send a broadcast or a message without subscribing in any module, and I can be able to receive this message in all LiveView modules.
To put it simply, I want to say I need to create a notification center and my all LV module are subscribed and receive it’s messages.
I imagine something like this in my mind that every section of my site after does a job send it their message as a notification.
Central and comprehensive notification
it should be noted Im forced not to use something can save my notifications in disk or db.
Thanks
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
mindok
Would a separate notification liveview embedded in your app.html.eex work? That could subscribe to the source of your notifications.
benwilson512
You want broadcasting without subscription? What does this mean? How would this work?
Can you elaborate on this requirement?
shahryarjb
Hi my friend, would you mind explaining me more please? how could embed this in my
app.html.eex?shahryarjb
Sorry my friend, I’m new in this subject. I just need to send a broadcast and get it in every page, how can I do this?
I mean if my user is here in every page of my site!! can see my message in his browser. now my user just can see my message when he is in the page concerned which has subscribe to same module and includes the same
handle_infofor example: I create a post in admin, I have 3 users are in these sections of my site. (1. shop, 2. blog, 3. support). I need all of them see my message that is
a new post has been createdin Same time!!mindok
So get a single liveview working to show notifications etc (i.e. subscribe to the source of the notifications and update the socket assigns when a notification is received).
Then display that liveview on every page by putting something like
in your
app.html.leexTo help you with how to subscribe to the source of notifications etc, we will need more information, but you will almost certainly end up using PubSub somewhere - you can read up on that here: Phoenix.PubSub – Phoenix v1.1.3
outlog
is it browser notifications? then this one shows you how: https://curiosum.dev/blog/elixir-phoenix-liveview-messenger-part-4
shahryarjb
I tested it, it works but but there is an error that I couldn’t fix.
if your client are in a page and don’t navigate to other page it is fine but if one of your clients navigate to other pages, it will be broken.
I created a video to explain, please see top right Notif box. I did 2 action {
deleteandcreate}if you saw the video, there are problems, like closing box or doesnt show notification message
my code:
notification LV
and it’s module:
one of the file I called it
and the other where I called with navigate:
in my app.html
full project:
Thanks
mindok
I’ll take a look first thing tomorrow Western Australian time…
shahryarjb
I took a small look at the source of my page:
the first
data-phx-sessionis my notification and the second is my main content. the second one allows is changed. but the first one after changing page it isn’t changed.maybe I should change it to something!?
I moved top code under
Leexfiles and change@connto@socketit had an error than forced me to put
idin mylive_render. and now It isn’t locked, every page it refresh’sdata-phx-sessionand cleans last notification.but there is still a problem, we have no
@socketinapp.htmland I can’t put it just once for now I put that line in all pages I havemindok
I took a look. I think there might be a liveview bug when a liveview is embedded within the layout (i.e.
live_renderinapp.html.leex) - alive_patchcauses the event handler to come detached. If you are able to create a minimal case to demonstrate that we can submit a bug report.When the
live_renderis added to each of your liveviews it seems to work ok. The notification gets cleared when you move from one page to another - there’s no avoiding that unless you have some kind of store of notifications and their statuses kept separately from the liveviews - it really depends on what user experience you want. Similarly, you won’t get a “category added” notification on the browser tab you added the category from - the notification fires before the liveview is created to “catch” it and display it. Again, you would need some kind of temporary store if you want your users to see this.I made a couple of minor changes to your notification liveview to allow display of multiple notifications. The list of notifications and logic for closing them could be moved to a separate process to provide the store mentioned above. Let us know your expected flow and we’ll have a go at making it work. I actually need something similar on a project I’m working on now, so the timing is good!