pub trait AutomaticKeepAliveClientMixin: State {
// Required methods
fn automatic_keep_alive_client_data(
self: Handle<Self>,
app: &App,
) -> &AutomaticKeepAliveClientMixinData;
fn automatic_keep_alive_client_data_mut(
self: Handle<Self>,
app: &mut App,
) -> &mut AutomaticKeepAliveClientMixinData;
fn want_keep_alive(self: Handle<Self>, app: &App) -> bool;
// Provided methods
fn update_keep_alive(self: Handle<Self>, app: &mut App) { ... }
fn init_state(self: Handle<Self>, app: &mut App) { ... }
fn deactivate(self: Handle<Self>, app: &mut App) { ... }
fn build(self: Handle<Self>, app: &mut App) -> WidgetRef { ... }
}Expand description
A mixin with convenience methods for clients of AutomaticKeepAlive. It is used
with State subclasses to manage keep-alive behavior in lazily built lists.
This mixin simplifies interaction with AutomaticKeepAlive by automatically
sending KeepAliveNotifications when necessary. Subclasses must implement
want_keep_alive to indicate whether the widget should be
kept alive and call update_keep_alive whenever its value
changes.
The mixin internally manages a KeepAliveHandle, which is used to notify
the nearest AutomaticKeepAlive ancestor of changes in keep-alive
requirements. AutomaticKeepAlive listens for KeepAliveNotifications sent
by this mixin and dynamically wraps the subtree in a KeepAlive widget to
preserve its state when it is no longer visible in the viewport.
Subclasses must implement want_keep_alive, and their
build methods must call AutomaticKeepAliveClientMixin::build
(though the return value should be ignored).
Then, whenever want_keep_alive’s value changes (or might
change), the subclass should call update_keep_alive.
The state holds an AutomaticKeepAliveClientMixinData under the field
automatic_keep_alive_client and implements the accessor pair. Rust cannot
interpose a mixin on State’s hooks, so the state’s own State::init_state,
State::deactivate and State::build call the counterparts here, where
Dart’s mixin body would run.
See also:
AutomaticKeepAlive, which listens to messages from this mixin.KeepAliveNotification, the notifications sent by this mixin.KeepAlivewhich marks a child as needing to stay alive even when it’s in a lazy list that would otherwise remove it.
Required Methods§
Sourcefn automatic_keep_alive_client_data(
self: Handle<Self>,
app: &App,
) -> &AutomaticKeepAliveClientMixinData
fn automatic_keep_alive_client_data( self: Handle<Self>, app: &App, ) -> &AutomaticKeepAliveClientMixinData
Mixin field access.
Sourcefn automatic_keep_alive_client_data_mut(
self: Handle<Self>,
app: &mut App,
) -> &mut AutomaticKeepAliveClientMixinData
fn automatic_keep_alive_client_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut AutomaticKeepAliveClientMixinData
Sourcefn want_keep_alive(self: Handle<Self>, app: &App) -> bool
fn want_keep_alive(self: Handle<Self>, app: &App) -> bool
Whether the current instance should be kept alive.
Call update_keep_alive whenever this getter’s value changes.
Provided Methods§
Sourcefn update_keep_alive(self: Handle<Self>, app: &mut App)
fn update_keep_alive(self: Handle<Self>, app: &mut App)
Ensures that any AutomaticKeepAlive ancestors are in a good state, by
firing a KeepAliveNotification or triggering the KeepAliveHandle as
appropriate.
Sourcefn init_state(self: Handle<Self>, app: &mut App)
fn init_state(self: Handle<Self>, app: &mut App)
The mixin’s part of State::init_state; the state calls it where Dart’s
super.initState() would reach the mixin.
Sourcefn deactivate(self: Handle<Self>, app: &mut App)
fn deactivate(self: Handle<Self>, app: &mut App)
The mixin’s part of State::deactivate; the state calls it where Dart’s
super.deactivate() would reach the mixin.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".