Morzaram

Morzaram

Hey guys, I went through Chris McCords Twitter clone video and made the code that shows the 1.6 version, along with doing a broadcast delete. Not sure how best practice the delete is, but everything is functional.

I guess this is really for those who are looking for up to date info since the syntax change of 1.6

1.6 Github Repo

If you think it’d be helpful, I’d be down to record this video and go through my code, let me know!

Showing Posts 1 to 5

PJextra

PJextra

That would be great, although due to the big effort involved you could wait a little bit more until next version of LiveView with the new Component API is out.

03juan

03juan

Thanks for the effort!

That does help keep the memory and data-transfer footprints down when doing phx-update="prepend" with temporary_assigns since the list comprehension over posts can just send the deleted post to the relevant PostComponent and all the action sends to the client is

c:
  2:
    0: "display:none;"
    4: "<a data-phx-link=\"patch\" data-phx-link-state=\"push\" href=\"/posts/1/edit\">Edit</a>"
    8: "Yes"

Otherwise you’d have to manually update the list stored in memory and remove the list item, or hit the DB to get all fresh posts and send all data again.

So it’s a nice convenience for deleting from a list, but I can’t see the temporary_assigns technique working with inserts when ordering is more complex, e.g. alphabetically by name.

Also, the idiomatic way to get the meta state is Ecto.get_meta(post, :state)

Morzaram

Morzaram OP

Hey Juan, thanks for the reply. I think I’ve implemented the delete functionality the way you said, unless I’m missing something. Otherwise, can you send me a snippet of what you mean? I’d really like to make this a best practice thing. I’m also considering making a guide much similar to Rails Guides if I’m able to gather enough resources, and guidance :slight_smile:

Thanks for the idiomatic way of doing things, there’s always something new to learn. haha

03juan

03juan

Sorry, sometimes I feel I don’t explain things as well as it sounds in my head. Could you elaborate on your confusion?

I think your implementation of delete is correct when using temporary_assigns.

Morzaram

Morzaram OP

All good! Sometimes my reading comprehension isn’t the best either. You answered my question :slight_smile:

— All posts loaded —

Where Next? Top

Trending in Other Resources Top

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
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews