Struct yew_nested_router::prelude::RouterContext
source · 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 target, but doesn’t leave the page.
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>where
T: Target + Clone,
impl<T> Clone for RouterContext<T>where T: Target + Clone,
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<RouterContext<T>> for RouterContext<T>where
T: Target + PartialEq,
impl<T> PartialEq<RouterContext<T>> for RouterContext<T>where T: Target + PartialEq,
source§fn eq(&self, other: &RouterContext<T>) -> bool
fn eq(&self, other: &RouterContext<T>) -> bool
self and other values to be equal, and is used
by ==.impl<T> StructuralPartialEq for RouterContext<T>where T: Target,
Auto Trait Implementations§
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> 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.