Nested stream does not update with stream_insert and stream_delete

Hi all,

After watching Chris McCord’s keynote about LiveView where he mentions nested streams, I realized this could solve a problem in my application. I’m having some trouble getting it to work though, and replicated what I was seeing in an example repo.

Code: GitHub - gcpreston/stream_test
Demo video: Nested streams issue demo - YouTube

Problem 1: The nested stream does not update with stream_insert and stream_delete

See NestedLive (third example in video). I feel I may not be implementing this in the most pragmatic way. I’m not sure what I would do about something like deleting streams. More importantly though, items aren’t added when stream_insert is called, but when I modify the code to put the stream at the top level, everything works as expected. This is demonstrated in SingleLive (first example in video).

Bonus: Problem 2

This is something I discovered when testing if managing multiple streams via an assign rather than an outer stream worked. Turns out, stream_insert works as expected, but stream_delete does not. See AssignLive (second example in video).

I’m interested to see the trello clone codebase when that comes out, but in the meantime, has anyone implemented this successfully? Does anyone have insight to why my code doesn’t work, or pointers for organizing logic better? And, does anyone know what the bug Chris mentions in the talk is?

Thank you!

3 Likes

Replying to this since TodoTrek got released :slight_smile: Looks like TodoTrek uses live components for the inner streams, which I suspected might be part of the solution. Additionally, the changelog mentions a bug where stream_delete wasn’t working for nested comprehensions, which I believe is what is being observed in Problem 2.

1 Like

If you don’t go with a live component for the nested stream, then to update any nested stream items requires stream_inserting against the parent and child, since the parent also needs to “change” for it’s children to be rendered since an empty parent stream won’t evaluate the inner block. The live component allows the nested stream to handle and updates itself without the dual stream operations everywhere.

3 Likes