feat: add create_query_signal_with_options to leptos_router (#2517)

This commit is contained in:
kryesh 2024-04-18 09:23:33 +10:00 committed by GitHub
parent 9a7dbd50eb
commit c1ebaf9d04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,6 +47,17 @@ use std::{rc::Rc, str::FromStr};
pub fn create_query_signal<T>(
key: impl Into<Oco<'static, str>>,
) -> (Memo<Option<T>>, SignalSetter<Option<T>>)
where
T: FromStr + ToString + PartialEq,
{
create_query_signal_with_options::<T>(key, NavigateOptions::default())
}
#[track_caller]
pub fn create_query_signal_with_options<T>(
key: impl Into<Oco<'static, str>>,
nav_options: NavigateOptions,
) -> (Memo<Option<T>>, SignalSetter<Option<T>>)
where
T: FromStr + ToString + PartialEq,
{
@ -77,7 +88,7 @@ where
let path = location.pathname.get_untracked();
let hash = location.hash.get_untracked();
let new_url = format!("{path}{qs}{hash}");
navigate(&new_url, NavigateOptions::default());
navigate(&new_url, nav_options.clone());
});
(get, set)