Closed gremo closed 8 months ago
Did you forget #[LiveProp] on $lastUpdated ?
And #[LiveAction] on getLastState ?
@smnandre #[LiveProp]
has no effect. About #[LiveAction]
, why do I need it if this is just a getter? Thanks
LiveProp is the way LiveComponent keep a property "state".
LiveAction is the way LiveComponent can act on its model while keeping previous "state".
If you use neither LiveAction nor LiveProp, your property will not be updated with its new value.
Oh I see, thank you. Sorry for being so naive, it was not clear to me!
No problem :)
In my
AttendancePanel
I'm usinggetLastState
to fetch a remote resource and, as soon as the method ends, I update the propertylastUpdated
(set it to the current date/time).In Twig, I'm using
this.lastState
(orcomputed.lastState
). Either waylastUpdated
isnull
, despite the fact that the method actually update the variable:On the contrary, if I call
record()
using a button (data-action-name="record"
) the last update time is updated just fine: