shahryarjb
I created an issue in LiveView GitHub: When `live_flash` is clicked, it cleans `temporary_assigns` inside a `live_component` · Issue #1960 · phoenixframework/phoenix_live_view · GitHub
My problem comes when I click on a live_flash.
I described in this video
And Jose told me:
This is intentional. if you declare something as temporary it will be cleared immediately after rendering and any other event won’t have that date anymore. You need to make sure that the variable is being properly changed tracked so it is not rerendered unless the variable itself changes.
But I could not understand how to track my variable. All the things work but when a user click on live_flash it clears all the temporary_assigns.
Thank you
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
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
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
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
Can you use a regular assign then not a temporary assign?
shahryarjb
Hi, I think for now no!! Because in my real-project it needs many changes. But as I said when I am using regular assign I have no problems.
Temporary solution that I test in a demo application is using
phx-hookto send a request tojsand delete the element like this:As Jose said
I did not do this in my project, I have many nested LiveView component to create modular UI and let developer create a duplicate page very fast, and it is impossible to change all of them for now.
Unfortunately, before update t worked for me, but I think some basic context were changed like
live_flashcan re-render mylive_componentFor example:
I am using temporary assign in my project because always the selected parts are updated, and I do not want to re-render or re-call all the database to improve my using resource. But some places in my project just was for theory, and they forced me to load all the data again even I used temporary assign there.
After 16 months of working on LiveView every day, I think the context changes are very high and can destroy release time, but another hand it is going to continue very excellent, and I am very grateful of LiveView team.
benwilson512
If you use a stateful component you don’t need to hit the database again either. Using temporary assigns this way is not really how they’re intended to be used, you need to be combining them with
phx-update=appendorprepend. They’re not a way to optimize out DB calls from stateless components.shahryarjb
Yes I have done like you said, but some places like changing like number of a post in a list are going to be a problem or bookmark a post and change its icon to bookmarked
benwilson512
Can you elaborate on what those problems are?
shahryarjb
For example, you have 50 posts with pagination, every page shows 15 post and somebody in the page 2 like a post and another people like a post in page 1. So I want every client in ever page can see a current like number of a post.
Like Twitter, you can see like number of a tweet real-time. But there is a difference, Twitter push all the tweets in a page, but I have pagination.
Please see this image (it is Persian but the heart is like)
How can update it without re-call from db. I create a
Pubsuband push an event and get this in my LiveViewhandle_infoif a post likes changed and my user in a page the like is changed I re-bind.Code:
tfwright
If you are just trying update a small piece of markup like the “bookmark” icon or something similar, have you considered just handling that manually in js, and using
phx-ignoreto protect it from LV updates?shahryarjb
Yes, I did this !! After the problem I sent in first post, I handle my problem with phoenix LiveView hook.
And for Like and Bookmark, I will do with
phx-hookin new version of my CMS, but usingphx-ignoreno I did not, I will try!! For now,phx-hookfixed my issue.I wanted to do this with LiveView because I have no information with JS security problems
tfwright
Sorry, I was having a hard time understanding the exact nature of your use case. FWIW, I have rarely needed to use
temporary_assignsbecause reloading a paginated set of db records is not usually a very expensive operation. And if it is, you can manually manage the list in other ways. If I am not misunderstanding, it sounds like, as others have pointed out, you have been using temporary_assigns for something it was not intended for and may have been only accidentally working. So if you want to avoid hooks you possibly can just switch toassigns?shahryarjb
For now, I do not think so, But can you give me a real world example where you use
temporary_assigns?Thank you for your consideration