pub struct Router<Msg> { /* private fields */ }Expand description
A reactive router that owns the current location and re-resolves the route table on navigation.
Router is cheap to clone (internally Rc-backed) and integrates with the
existing reactive Signal so effects subscribed to Router::signal
re-run on every navigation — that is how a backend rebuilds the UI tree.
Implementations§
Source§impl<Msg> Router<Msg>
impl<Msg> Router<Msg>
Sourcepub fn new(table: RouteTable<Msg>, initial_path: &str) -> Self
pub fn new(table: RouteTable<Msg>, initial_path: &str) -> Self
Builds a router from a RouteTable, starting at initial_path.
Sourcepub fn current_path(&self) -> String
pub fn current_path(&self) -> String
The current path.
Navigates to path, updating the location signal (which re-triggers any
subscribed effects). A backend typically also syncs the browser URL.
Sourcepub fn signal(&self) -> Signal<String>
pub fn signal(&self) -> Signal<String>
Returns the location signal so effects can subscribe to navigation.
Sourcepub fn current_view(&self) -> UITree<Msg>
pub fn current_view(&self) -> UITree<Msg>
Resolves the current path to a view.
Trait Implementations§
Auto Trait Implementations§
impl<Msg> !RefUnwindSafe for Router<Msg>
impl<Msg> !Send for Router<Msg>
impl<Msg> !Sync for Router<Msg>
impl<Msg> !UnwindSafe for Router<Msg>
impl<Msg> Freeze for Router<Msg>
impl<Msg> Unpin for Router<Msg>
impl<Msg> UnsafeUnpin for Router<Msg>
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
Mutably borrows from an owned value. Read more