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

woylie
We are seeing a lot of warning logs like this: navigate event to "https://someurl" failed because you are redirecting across live_sessio...
New

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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews