Adding in routing::current_url function
This commit is contained in:
parent
ca6aba0a93
commit
50b7b00f64
|
@ -41,16 +41,16 @@ impl<A> State<A> {
|
|||
}*/
|
||||
|
||||
|
||||
fn current_url() -> String {
|
||||
fn current_url_string() -> String {
|
||||
window().location().unwrap().href().unwrap()
|
||||
}
|
||||
|
||||
// TODO inline ?
|
||||
fn change_url(mutable: &Mutable<Url>) {
|
||||
let new_url = current_url();
|
||||
|
||||
let mut lock = mutable.lock_mut();
|
||||
|
||||
let new_url = current_url_string();
|
||||
|
||||
// TODO test that this doesn't notify if the URLs are the same
|
||||
// TODO helper method for this
|
||||
// TODO can this be made more efficient ?
|
||||
|
@ -68,7 +68,7 @@ struct CurrentUrl {
|
|||
impl CurrentUrl {
|
||||
#[inline]
|
||||
fn new() -> Self {
|
||||
let value = Mutable::new(Url::new(¤t_url()));
|
||||
let value = Mutable::new(Url::new(¤t_url_string()));
|
||||
|
||||
let callback = {
|
||||
let value = value.clone();
|
||||
|
@ -106,6 +106,12 @@ lazy_static! {
|
|||
}
|
||||
|
||||
|
||||
#[inline]
|
||||
pub fn current_url() -> Url {
|
||||
URL.value.get_cloned()
|
||||
}
|
||||
|
||||
|
||||
#[inline]
|
||||
pub fn url() -> impl Signal<Item = Url> {
|
||||
URL.value.signal_cloned()
|
||||
|
|
Loading…
Reference in New Issue