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
1 changed files with 12 additions and 1 deletions

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)