pub struct RouteObserver { /* private fields */ }Expand description
A Navigator observer that notifies RouteAwares of changes to the state of their
Route.
RouteObserver informs subscribers whenever a route the matches predicate accepts is
pushed on top of their own matching route or popped from it. This is for example useful to
keep track of page transitions: a RouteObserver built with AnyRoute::as_page_route will
inform subscribed RouteAwares whenever the user navigates away from the current page
route to another page route.
See also:
RouteAware, which is used withRouteObserverto make a widget aware of changes to theNavigator’s session history.
Implementations§
Source§impl RouteObserver
impl RouteObserver
Sourcepub fn new(app: &mut App, matches: RoutePredicate) -> Ref<RouteObserver>
pub fn new(app: &mut App, matches: RoutePredicate) -> Ref<RouteObserver>
Creates an observer of the routes matches accepts; Dart’s type argument R.
Sourcepub fn debug_observing_route(
self: Handle<Self>,
app: &App,
route: AnyRoute,
) -> bool
pub fn debug_observing_route( self: Handle<Self>, app: &App, route: AnyRoute, ) -> bool
Whether this observer is managing changes for the specified route.
If debug assertions are disabled, this method always returns false.
Sourcepub fn subscribe(
self: Handle<Self>,
app: &mut App,
route_aware: Rc<dyn RouteAware>,
route: AnyRoute,
)
pub fn subscribe( self: Handle<Self>, app: &mut App, route_aware: Rc<dyn RouteAware>, route: AnyRoute, )
Subscribes route_aware to be informed about changes to route.
Going forward, route_aware will be informed about qualifying changes to route, e.g.
when route is covered by another route or when route is popped off the Navigator
stack.
Sourcepub fn unsubscribe(
self: Handle<Self>,
app: &mut App,
route_aware: Rc<dyn RouteAware>,
)
pub fn unsubscribe( self: Handle<Self>, app: &mut App, route_aware: Rc<dyn RouteAware>, )
Unsubscribes route_aware.
route_aware is no longer informed about changes to its route. If the given argument
was subscribed to multiple routes, this unregisters it (once) from each.
Trait Implementations§
NavigatorObserver._navigators entry, held under the field navigator_observer
(navigator_observer_accessors!).Source§fn did_pop(
self: Handle<Self>,
app: &mut App,
route: AnyRoute,
previous_route: Option<AnyRoute>,
)
fn did_pop( self: Handle<Self>, app: &mut App, route: AnyRoute, previous_route: Option<AnyRoute>, )
Source§fn did_push(
self: Handle<Self>,
app: &mut App,
route: AnyRoute,
previous_route: Option<AnyRoute>,
)
fn did_push( self: Handle<Self>, app: &mut App, route: AnyRoute, previous_route: Option<AnyRoute>, )
Source§fn as_observer(self: Handle<Self>) -> AnyNavigatorObserver
fn as_observer(self: Handle<Self>) -> AnyNavigatorObserver
AnyNavigatorObserver.