pub struct GlobalRouter { /* private fields */ }Expand description
Global router state accessible from any component
Implementations§
Source§impl GlobalRouter
impl GlobalRouter
Sourcepub fn push_named(
&mut self,
name: &str,
params: &RouteParams,
) -> Option<RouteChangeEvent>
pub fn push_named( &mut self, name: &str, params: &RouteParams, ) -> Option<RouteChangeEvent>
Navigate to a named route with parameters
Sourcepub fn url_for(&self, name: &str, params: &RouteParams) -> Option<String>
pub fn url_for(&self, name: &str, params: &RouteParams) -> Option<String>
Generate URL for a named route
Sourcepub fn push(&mut self, path: String) -> RouteChangeEvent
pub fn push(&mut self, path: String) -> RouteChangeEvent
Navigate to a path
Sourcepub fn replace(&mut self, path: String) -> RouteChangeEvent
pub fn replace(&mut self, path: String) -> RouteChangeEvent
Replace current path
Sourcepub fn back(&mut self) -> Option<RouteChangeEvent>
pub fn back(&mut self) -> Option<RouteChangeEvent>
Go back
Sourcepub fn forward(&mut self) -> Option<RouteChangeEvent>
pub fn forward(&mut self) -> Option<RouteChangeEvent>
Go forward
Sourcepub fn current_path(&self) -> &str
pub fn current_path(&self) -> &str
Get current path
Sourcepub fn current_match(&mut self) -> Option<RouteMatch>
pub fn current_match(&mut self) -> Option<RouteMatch>
Get current route match (with caching, requires mutable)
Sourcepub fn current_match_immutable(&self) -> Option<RouteMatch>
pub fn current_match_immutable(&self) -> Option<RouteMatch>
Get current route match (immutable, no caching)
Use this from Render implementations and other immutable contexts
Sourcepub fn current_route(&self) -> Option<&Arc<Route>>
pub fn current_route(&self) -> Option<&Arc<Route>>
Get the current matched Route
Returns the shared Arc<Route> that matched the current path.
Useful for accessing the route’s children and builder without cloning.
Sourcepub fn can_go_back(&self) -> bool
pub fn can_go_back(&self) -> bool
Check if can go back
Sourcepub fn can_go_forward(&self) -> bool
pub fn can_go_forward(&self) -> bool
Check if can go forward
Sourcepub fn state_mut(&mut self) -> &mut RouterState
pub fn state_mut(&mut self) -> &mut RouterState
Get mutable state reference
Sourcepub fn state(&self) -> &RouterState
pub fn state(&self) -> &RouterState
Get state reference
Sourcepub fn nested_cache_mut(&mut self) -> &mut RouteCache
Available on crate feature cache only.
pub fn nested_cache_mut(&mut self) -> &mut RouteCache
cache only.Get nested route cache (mutable)
Sourcepub fn cache_stats(&self) -> &CacheStats
Available on crate feature cache only.
pub fn cache_stats(&self) -> &CacheStats
cache only.Get nested route cache statistics
Sourcepub fn set_next_transition(&mut self, transition: Transition)
Available on crate feature transition only.
pub fn set_next_transition(&mut self, transition: Transition)
transition only.Set transition for the next navigation
This override will be used for the next push/replace operation, then automatically cleared.
§Example
use gpui_navigator::{GlobalRouter, Transition};
cx.update_global::<GlobalRouter, _>(|router, _| {
router.set_next_transition(Transition::fade(300));
router.push("/page".to_string());
});Sourcepub fn take_next_transition(&mut self) -> Option<Transition>
Available on crate feature transition only.
pub fn take_next_transition(&mut self) -> Option<Transition>
transition only.Get and consume the next transition override
Returns the transition override if set, and clears it. Used internally by navigation methods.
Sourcepub fn has_next_transition(&self) -> bool
Available on crate feature transition only.
pub fn has_next_transition(&self) -> bool
transition only.Check if there’s a transition override set
Sourcepub fn clear_next_transition(&mut self)
Available on crate feature transition only.
pub fn clear_next_transition(&mut self)
transition only.Clear transition override without consuming it
Sourcepub fn push_with_transition(
&mut self,
path: String,
transition: Transition,
) -> RouteChangeEvent
Available on crate feature transition only.
pub fn push_with_transition( &mut self, path: String, transition: Transition, ) -> RouteChangeEvent
transition only.Sourcepub fn replace_with_transition(
&mut self,
path: String,
transition: Transition,
) -> RouteChangeEvent
Available on crate feature transition only.
pub fn replace_with_transition( &mut self, path: String, transition: Transition, ) -> RouteChangeEvent
transition only.Replace with a specific transition
Trait Implementations§
Source§impl Clone for GlobalRouter
impl Clone for GlobalRouter
Source§fn clone(&self) -> GlobalRouter
fn clone(&self) -> GlobalRouter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for GlobalRouter
impl Default for GlobalRouter
impl Global for GlobalRouter
Auto Trait Implementations§
impl Freeze for GlobalRouter
impl !RefUnwindSafe for GlobalRouter
impl Send for GlobalRouter
impl Sync for GlobalRouter
impl Unpin for GlobalRouter
impl !UnwindSafe for GlobalRouter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReadGlobal for Twhere
T: Global,
impl<T> ReadGlobal for Twhere
T: Global,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().