shahryarjb

shahryarjb

How to track the variable is being properly changed in LiveView

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

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Can you use a regular assign then not a temporary assign?

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Can you elaborate on what those problems are?

tfwright

tfwright

Sorry, I was having a hard time understanding the exact nature of your use case. FWIW, I have rarely needed to use temporary_assigns because 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 to assigns?

Last Post!

cmo

cmo

When you don’t need that data anymore. So you’re either happy to fetch it again or you don’t need it because your pre/appending to the list. See below for the append case.

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
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
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
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
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
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
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
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
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
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement