Repeater optimistic UI with livewire
Hi all,
Does anyone have any pointers on how to implement an optimistic UI using the Livewire repeater?
I was thinking of using alpine to do so, so I was wondering if anybody already attempted something similar / has any pointers on this.
Thanks!
4 Replies
What exactly would be optimistic about it?
Specifically I am looking to alter the "Add " / "Delete"-actions to rapidly display / remove a new record without a roundtrip.
So when clicking, a new row gets added (or the row gets deleted) without doing a roundtrip.
Deleting the record seems quite doable.
But I am afraid that creating a new item will be pretty tricky (generating new form elements that play nicely with the current livewire BE actions, which also can be altered afterwards using the $get and $set seem a bit harder).
Yea. The form state is in livewire so a round trip is necessary to update the form state. I think it could potentially be done but with a custom repeater and not out of the box.
Could be wrong, but doesn’t really feel like optimistic ui to me. In my mind optimistic would be assuming the saved form state before processing the form.
Yea. Figured as much. Hmmn, OK, let me go down the rabbithole ^^. I will report back when I got it working :D.
Jep, I agree on the "optimistic" comment. In my mind it was something like: "Show what the UI would be before the roundtrip happens. So I didn't know how to differently name it than "optimistic UI".
Thanks for the answer!