lemaster

lemaster

Currently we have stream_insert and stream that can either add new items to a stream or update existing items if they are already present on the client. It would be good to also have stream_update (or alternatively an update_only: true/false option) that would update an existing stream item if it is present on the client side or ignore the item if it is not already present.

The use case is a bunch of users editing items in a tableview of a potentially large data set. If 2 users can see the same item, it would be nice to show the items updating, but if both users are looking at different portions of the dataset, i don’t want items popping into view just because the other user updated them.

I have some time to help to implement the feature, but I would need someone to walk me through the interaction between the LiveView’s concept of the stream on the server side and client side version of the stream first. Alternatively, if there’s a way to handle this use case with the existing streams api, I’m happy to learn.

Showing Posts 1 to 2

steffend

steffend

Phoenix Core Team

Hey @lemaster,

this reminded me of Updating a stream element without inserting · Issue #2690 · phoenixframework/phoenix_live_view · GitHub.

I also opened stream_insert update_only aka stream_update by SteffenDE · Pull Request #3573 · phoenixframework/phoenix_live_view · GitHub, where you can see how this could be implemented. There are no tests yet, because I first wanted to see if José thinks that now’s the right time.

If anyone wonders how to do this in the meantime: you can implement this by keeping a MapSet of rendered ids in your assigns and only stream_inserting if the ID is in the set.

lemaster

lemaster OP

Wow, thanks for jumping on this! I think the solution in your PR is much better than maintaining a MapSet on the server. If you are using a limit with the stream, rather than maintaining a MapSet, you would need to maintain a list, and duplicate the logic of the stream yourself. If you mess up there’s a real chance of your stream diverging from your id list.

— All posts loaded —

Where Next? Top

Trending in Proposals: Ideas Top

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
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
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews