Owens

Owens

WhatsApp-style UI with LiveView -- Subscribe To All Channels At Once?

Hello all, I’m building a LiveView Chat App and recreating the interface to be like WhatsApp’s Desktop app.

As you can see, the right side is the current chat room, but the left side is a list of every chat room the user is in and it shows updates in realtime to those rooms too.

My question is, what is the most efficient channel strategy for this?

  1. Have the user be subscribed to the channel for every single room he is in? Updates are sent to each room’s channel normally.
  2. Have the user be subscribed to the current chat room channel, and his own channel which is used to update the index view on the left (e.g. “user21_chat_index”). Then, whenever a message is created or updated, it sends the chat over the room channel and to each user’s personal channel.
  3. A different approach from the two above.

Thanks in advance to those who have created something like this before.

Marked As Solved

prihandi

prihandi

IMHO, It should use no.2 strategy.

User should subscribe to:

  1. user own channel ( to render chat list / left side)
  2. room channel that currently opened (to render room and messages / right side )

In my previous experience I would also separate presence channel and typing channel, for it’s logic dependency, especially typing , it’s quite crowded and need minimal logic intervention.

Also Liked

carterbryden

carterbryden

Hey Trevor, I’d do option 2. Subscribing to as many channels as you have conversations feels wrong to me, though I don’t actually know how efficient it would or wouldn’t be.

Edit: either way I’m betting you’d probably have to be at very large scale before it’s an issue, and it’d be easy to change later.

kaashyapan

kaashyapan

I’d pick 1.

I did a Helpdesk chat application which is a little different than the concern here.
I had a lobby room and a room for each user.
The helpdesk admin joins the users room after the user turns up in the lobby.
The lobby room is used to indicate presence.

It has worked OK so far. I think the question is scale.
I’d pick whatever most closely resembles communication in the real world.

Where Next?

Popular in Questions Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New

Other popular topics Top

WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement