Qqwy

Qqwy

TypeCheck Core Team

Phoenix design question: AJAX vs Channels for update form

I am creating an app where people can create items and put them into collections.

To give it a ‘single page app’-like feel, I want people to be able to click on an ‘edit’ icon and edit and update one of the items in-place.

Now there is a choice here to use AJAX to do the updating behind-the-scenes, or to use Phoenix Channels.
One advantage that channels might have, is that a user could listen to each item’s topic, and also be notified when another user makes a change in one of the items.

However, the application will contain hundreds of items per collection, meaning that users might subscribe to many, many topics while they browse through a collection. Would this pose a problem?

Also, I wonder what the best way would be to serialize a form while using Phoenix Channels.

What is the better option here?

Most Liked

OvermindDL1

OvermindDL1

Each topic subscribed from a Phoenix Channel is a new process, so keep that in mind. :slight_smile:

What I’ve done is have a single manager process, but the webpage sends messages to it saying ‘I want to be subscribed to this information’, it then internally calls MyEndpoint.subscribe/3 for each appropriate thing, which then all binds to ‘this’ one process, so no process spam then. I wish there were an interface to simplify this pattern as I use it a surprising amount, but it is very easy to do as it is. :slight_smile:

You can get a json of the form information via javascript, easy to pass that back over then. :slight_smile:

You can even call that one parse function on Plug to have it parse its special list and such syntax too.

Where Next?

Popular in Questions Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
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
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
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
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
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
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
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
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
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
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement