Skip to main content

RouteObserver

Struct RouteObserver 

Source
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:

Implementations§

Source§

impl RouteObserver

Source

pub fn new(app: &mut App, matches: RoutePredicate) -> Ref<RouteObserver>

Creates an observer of the routes matches accepts; Dart’s type argument R.

Source

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.

Source

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.

Source

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§

Source§

impl NavigatorObserver for RouteObserver

Source§

fn navigator_observer_data( self: Handle<Self>, app: &App, ) -> &NavigatorObserverData

Dart’s NavigatorObserver._navigators entry, held under the field navigator_observer (navigator_observer_accessors!).
Source§

fn navigator_observer_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut NavigatorObserverData

Source§

fn did_pop( self: Handle<Self>, app: &mut App, route: AnyRoute, previous_route: Option<AnyRoute>, )

The Navigator popped route. Read more
Source§

fn did_push( self: Handle<Self>, app: &mut App, route: AnyRoute, previous_route: Option<AnyRoute>, )

The Navigator pushed route. Read more
Source§

fn as_observer(self: Handle<Self>) -> AnyNavigatorObserver

This observer as the erased AnyNavigatorObserver.
Source§

fn navigator(self: Handle<Self>, app: &App) -> Option<Handle<NavigatorState>>

The navigator that the observer is observing, if any.
Source§

fn did_remove( self: Handle<Self>, app: &mut App, route: AnyRoute, previous_route: Option<AnyRoute>, )

The Navigator removed route. Read more
Source§

fn did_replace( self: Handle<Self>, app: &mut App, new_route: Option<AnyRoute>, old_route: Option<AnyRoute>, )

The Navigator replaced old_route with new_route.
Source§

fn did_change_top( self: Handle<Self>, app: &mut App, top_route: AnyRoute, previous_top_route: Option<AnyRoute>, )

The top most route has changed. Read more
Source§

fn did_start_user_gesture( self: Handle<Self>, app: &mut App, route: AnyRoute, previous_route: Option<AnyRoute>, )

The Navigator’s routes are being moved by a user gesture. Read more
Source§

fn did_stop_user_gesture(self: Handle<Self>, app: &mut App)

User gesture is no longer controlling the Navigator. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for RouteObserver

§

impl !Send for RouteObserver

§

impl !Sync for RouteObserver

§

impl !UnwindSafe for RouteObserver

§

impl Forget for RouteObserver

§

impl Freeze for RouteObserver
where NonZero<u32>: Freeze, PhantomData<fn() -> NavigatorState>: Freeze, *const RcInner<dyn Fn(&mut App, AnyRoute) -> bool> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyRoute) -> bool>>: Freeze, *const u8 is !null: Freeze, PhantomData<(Retained<AnyRoute>, Vec<Rc<dyn RouteAware>>)>: Freeze,

§

impl Move for RouteObserver

§

impl Unpin for RouteObserver
where NonZero<u32>: Unpin, Rc<dyn Fn(&mut App, AnyRoute) -> bool>: Unpin, *const u8 is !null: Unpin, &'static RouteVTable: Unpin, Rc<Keep>: Unpin, Rc<dyn RouteAware>: Unpin,

§

impl UnsafeUnpin for RouteObserver
where NonZeroU32Inner: UnsafeUnpin, PhantomData<fn() -> NavigatorState>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyRoute) -> bool> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyRoute) -> bool>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<(Retained<AnyRoute>, Vec<Rc<dyn RouteAware>>)>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>