Refresh only current client #4513
Replies: 2 comments 10 replies
-
That's interesting, but if I remember correctly, that you can use the local scope version of ui.refreshable if you always want to refresh only the client who, say, clicked a button. https://nicegui.io/documentation/refreshable However, this is an interesting possibility, though. Not sure when it would be useful, since the state which should be uniform across all clients in a global scope ui.refreshable falls apart with your approach, so do you want a uniform global state or independent state after all 😅 |
Beta Was this translation helpful? Give feedback.
-
Ok. I guess we can close this discussion: there is no new feature to be implemented. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I've been using nicegui for a few months now and it is great, thanks to whoever is contributing and maintaining it.
My typical use-case is showing a table that can be filtered, and its elements can be added, edited, removed.. The usual stuff.
About filtering, #1029 helped a lot.
What still bothered me is that when one client was filtering their table, all of the clients' tables were being refreshed too.
Of course I'm ok with the refresh happening when adding/editing/removing elements: live update is great, but it shouldn't happen for filters.
Very much simplified, the code looked like:
(taken from #1029 (comment) and slightly edited)
Here we are not filtering but the point is the same: you will notice that when switching "Uppercase", all the clients get updated.
I went through the source code (thanks Open Source!) and ended up implementing the following:
This is not battle tested yet, but it allows to refresh only the client that is asking for the refresh.
The only change needed to use this class is:
so the full code becomes:
Here you will notice that when switching "Uppercase", only one client is updated.
On the other hand, when adding a new element, all the clients get updated and retain their "Uppercase" state.
It would be nice to have this feature implemented, or maybe that's only me showing off, or maybe there other ways to achieve this, feel free to move the discussion in the appropriate section.
Let me know what you think!
Beta Was this translation helpful? Give feedback.
All reactions