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 2 to 1

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.

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.

— All posts loaded —

Where Next? Top

Trending in Proposals: Ideas Top

a3kov
I recently learned about this API and was surprised there’s no explicit support for it in the the Phoenix. Example use cases: A webs...
New

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
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
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
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews