pedroperrone
Hello, Elixir Forum
I’ve recently started playing around with Phoenix Live View and read about the use of temporary assigns in sockets to allow us to reduce the amount of memory used by the server. I’m trying to build a todo list and am using the list of tasks as a temporary assign. For my list of tasks component I’m using phx-update=“prepend”. In this scenario, adding and updating tasks work perfectly. However, I got stuck in the delete feature. If the option phx-update=“prepend” only adds and updates elements, how can I remove them from the list? If it can’t be done with the prepend option, how can I have the benefits of temporary assigns and be able to perform deletions at the same time?
Thanks in advanced ![]()
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
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
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
Wrote about how to safely run a globally unique process in an Elixir cluster, and a scary story from the past!
Learn about :global for r...
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
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sfusato
You could fetch the (new) to-do list and use
phx-update="replace". Then on all the other actions you would go back tophx-update="prepend".srowley
I have been thinking about the same thing in the context of charting. Imagine a line plot of time series data that is updated every second, and I want to show the last 24 hours. For that use case I really do not want to replace all 86,400 data points every second. Temporary assigns seem like the obvious solution, except for the fact that I don’t think that I can delete the oldest data point after appending a new one. If there is a way to do that/work around it I would be really interested in that.
sfusato
In this case, where updating happens frequently and you have a large collection as opposed to a delete every once in a while on a rather small collection, I would remove the item within an
updatedmethod hook placed on the list. Something like:Since
updatedgets called every time you add a new item, it works beautifully as you only have to remove either the first or last depending if you eitherappendorprepend.To arbitrarily remove a specific item, you could add a data attribute to the hook passing in the selector of the node to delete:
data-deleted="<%= @deleted %>"snap
I’m trying something similar with rendering a list of (unseen) notifications that can be marked as seen.
When I try rendering only unseen notifications using
unless notification.seenit doesn’t update the list because ofphx-update="prepend".When I set a
seenclass applyingdisplay: none;to the notification hides, but I would prefer to remove it and hit theelsestatement rendering the “No notifications” message.What this require fetching the whole notifications list again and update it by temporary setting
phx-update="replace"?Recommendations are welcome, thanks in advance!