Qqwy
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
Each topic subscribed from a Phoenix Channel is a new process, so keep that in mind. ![]()
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. ![]()
You can get a json of the form information via javascript, easy to pass that back over then. ![]()
You can even call that one parse function on Plug to have it parse its special list and such syntax too.
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
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









