arrowsmith

arrowsmith

Can someone clarify what this sentence means in the docs for LiveComponent?

The assigns received as the first argument of the update/2 callback will only include the new assigns passed from this function. Pre-existing assigns may be found in socket.assigns.

I don’t get it - under what circumstances is an assign considered “new”? Afaict all assigns always get passed, even the ‘old’ ones.

E.g. say that @bar = 1 in my parent LV, then I have:

<.live_component component={Something} id="id" foo="foo" bar={@bar} />

Then if I stick an IO.inspect in Something.update/2 I see that assigns is %{id: "id", foo: "foo", bar: 1}.

Then say I update the value of @bar to 2, which triggers another update. If I’m reading the docs correctly then only the bar assign should be passed to update/2 this time, but from IO.inspect I can see that the assigns passed to update/2 is now %{id: "id", foo: "foo", bar: 2} - all the keys are included, not just the “new” one.

This is still the case if I engineer some contrived situation where live_component/1 doesn’t receive the key at all on the first update but receives it on later updates… all of the original keys are still included on every update.

The docs imply that an attribute/value pair passed to live_component/1 might not always be passed to update/1, but I can’t see how this is ever actually the case. What am I not understanding?

Showing Posts 1 to 1

cmo

cmo

That is a confusing sentence. What function is it referring to as “this function”?

I would expect only new assigns are passed to update when the Live component is updated via send_update.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
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
nseaSeb
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
RemyXRenard
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
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
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
samoloth
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
FlyingNoodle
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 Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews