thojanssens1
When subscribing to a topic, how do I get the last message that was broadcasted?
Use case: A document is shared for editing, but it can have only one editor at a time. When someone request access for edition, a message is broadcasted to all subscribers.
Problem: when someone subscribes later (i.e. after the editor has been designated), that subscriber won’t know who is the editor. How can this subscriber get the last message that was broadcasted, in order to be up-to-date with the state?
More concretely, people join a room, a LiveView, where a document is editable. The document is editable only by one user at the time, there is some checkbox which allows locking/unlocking edition access. When the editor is changing, the new editor is broadcasted.
Problem: If someone joins that room/LiveView later on, he doesn’t know who is editing (and that is really annoying as he thinks no one is editing, and can lock the document for edition while someone was editing).
Most Liked
shanesveller
AFAIK, Phoenix PubSub channels are (fairly intentionally) not durable for clients that were not connected at the time. You will need to pursue some other form of coordination or persistence. Perhaps new clients can publish a request to know the current editor upon joining, or you could expose that aspect through a non-channel request.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









