pub struct RouterContext<T>where
T: Target,{
pub active_target: Option<T>,
/* private fields */
}
Fields§
§active_target: Option<T>
Implementations§
Source§impl<T> RouterContext<T>where
T: Target,
impl<T> RouterContext<T>where
T: Target,
Sourcepub fn push(&self, target: T)
pub fn push(&self, target: T)
Push a new state to the history. This changes the current page, but doesn’t actually leave the page.
Sourcepub fn replace(&self, target: T)
pub fn replace(&self, target: T)
Replace current state on the history. This changes the current page, but doesn’t actually leave the page.
Sourcepub fn push_with(&self, target: T, state: State)
pub fn push_with(&self, target: T, state: State)
Push a new state to the history, allow setting page state at the same time.
Sourcepub fn replace_with(&self, target: T, state: State)
pub fn replace_with(&self, target: T, state: State)
Replace current state on the history, allow setting page state at the same time.
Sourcepub fn render_target(&self, target: T) -> String
pub fn render_target(&self, target: T) -> String
Render the path of target.
This includes the parenting scopes as well as the “base” URL of the document.
Sourcepub fn render_target_with(
&self,
target: T,
state: impl IntoPropValue<State>,
) -> String
pub fn render_target_with( &self, target: T, state: impl IntoPropValue<State>, ) -> String
Render the path of target.
This includes the parenting scopes as well as the “base” URL of the document. It also adds the state using the hash.
Sourcepub fn is_active(
&self,
target: &T,
predicate: Option<&Callback<T, bool>>,
) -> bool
pub fn is_active( &self, target: &T, predicate: Option<&Callback<T, bool>>, ) -> bool
Check if the target is active.
This is intended for components to find out if their target, or part of their target
is active. If the function is provided with a predicate, then this will override the
decision process. Otherwise function will check if the provided target
is the same as
the active target.
Assume you have a nested navigation tree. The active state of a leaf entry would be identified by the target being “the same”. While branch entries would need to provide a predicate, as there is no “value” to compare to.
A component supporting this model can provide two properties: a target, and an optional predicate. The user can then configure this accordingly. The component can simply pass the information to this function to perform the check.
Trait Implementations§
Source§impl<T> Clone for RouterContext<T>
impl<T> Clone for RouterContext<T>
Source§fn clone(&self) -> RouterContext<T>
fn clone(&self) -> RouterContext<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T> PartialEq for RouterContext<T>
impl<T> PartialEq for RouterContext<T>
impl<T> StructuralPartialEq for RouterContext<T>where
T: Target,
Auto Trait Implementations§
impl<T> Freeze for RouterContext<T>where
T: Freeze,
impl<T> !RefUnwindSafe for RouterContext<T>
impl<T> !Send for RouterContext<T>
impl<T> !Sync for RouterContext<T>
impl<T> Unpin for RouterContext<T>where
T: Unpin,
impl<T> !UnwindSafe for RouterContext<T>
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> 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> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self
to a value of a Properties
struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self
to a value of a Properties
struct.