-
Notifications
You must be signed in to change notification settings - Fork 963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating a stream element without inserting #2690
Comments
Hi @SteffenDE, we are mostly focused on improving the current streams for now as we head towards v1.0. We can discuss new features in the future, but not our focus at the moment. :) |
Hmm okay, I see. Do you think it might make sense to leave the issue open to keep track of this feature then? Other question would be: would you mind a PR that implements a functionality like this, or do you think that this does not fit into the current plan for streams in general? |
Our focus is on solving the bug reports and merging the bug fixes today. It is unlikely we will prioritize new features until v1.0 is out. |
Btw, I am just trying to be upfront about expectations. :) I don't want you to work on a PR or promote discussions that won't receive attention any time soon. |
Fixes #2690. Relates to: https://elixirforum.com/t/add-stream-update-to-liveview-streams/68107 Work in progress, no tests yet.
Fixes #2690. Relates to: https://elixirforum.com/t/add-stream-update-to-liveview-streams/68107 Work in progress, no tests yet.
Fixes #2690. Relates to: https://elixirforum.com/t/add-stream-update-to-liveview-streams/68107 Work in progress, no tests yet.
Fixes #2690. Relates to: https://elixirforum.com/t/add-stream-update-to-liveview-streams/68107 Work in progress, no tests yet.
This is more of a feature request / discussion. Assume that you are rendering an infinitely scrollable table and are listening to changes using PubSub. When a PubSub message arrives, you want to update the element in the DOM, but only if is is actually currently rendered. If the element is not in the DOM, you do not want to insert it.
This can currently be achieved in some cases, e.g. when using pagination and there is a fixed page size. Then we can use
at: -1, limit: rows_per_page
which wants to append at the end, but limits the items to the number of items on the page. But even in this simple case this will fail if there is a page that is not already full. It also does not work in the example when using an infinite scrolled page that limits the maximum number of elements to, e.g., 3x the page size to have some buffer. On initial render, we render N items (limit is 3*N), therefore a stream_insert with limit 3*N would still append the element.So I'd like to propose a function
stream_update(stream, element)
that can be used to update an element of a stream, if it is currently in the DOM that does not insert non-existing elements. What do you think?The text was updated successfully, but these errors were encountered: