annie.pages.refresh¶
Client-scoped refreshables: a refresh redraws only the browser tab that acted (UI helper).
NiceGUI’s @ui.refreshable keeps one target per browser tab that built the view, and
refresh() rebuilds all of them. Annie’s views are module-level functions, so every
keystroke, click or tab switch in one tab used to rebuild that view in every open tab, all
on the one event loop.
client_refreshable is a drop-in replacement:
refresh()called while handling a tab (a NiceGUI page context is active) rebuilds only that tab’s target. Other tabs catch up when they next build or open the view.refresh()called with no page context (start-up, a background service) rebuilds every tab, as before.client_refreshable.refresh_everywhere()rebuilds every tab on purpose, for data that every open tab must show at once.client_refreshable.refresh_others()rebuilds every tab except the acting one, for a data change whose acting tab will rebuild the view anyway when it next opens it.
Classes¶
|
Module Contents¶
- class annie.pages.refresh.client_refreshable(func: collections.abc.Callable[_P, _T])[source]¶
Bases:
nicegui.functions.refreshable.refreshable@ui.refreshablewhoserefresh()rebuilds only the acting tab (see module docs).Refreshable UI functions
The
@ui.refreshabledecorator allows you to create functions that have arefreshmethod. This method will automatically delete all elements created by the function and recreate them.For decorating refreshable methods in classes, there is a
@ui.refreshable_methoddecorator, which is equivalent but prevents static type checking errors.- refresh(*args: Any, **kwargs: Any) nicegui.awaitable_response.AwaitableResponse[source]¶
Rebuild the acting tab’s view, or every tab when no tab is acting.
Accepts the same arguments as the view function (or a subset), like NiceGUI’s.