mirror of
https://github.com/leptos-rs/leptos.git
synced 2025-12-28 13:43:01 -05:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
faf0cb3378 |
@@ -24,35 +24,7 @@ use reactive_graph::{
|
||||
prelude::*,
|
||||
signal::{ArcRwSignal, RwSignal},
|
||||
};
|
||||
use std::{
|
||||
future::{pending, IntoFuture},
|
||||
ops::Deref,
|
||||
panic::Location,
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
};
|
||||
|
||||
static IS_SUPPRESSING_RESOURCE_LOAD: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
pub struct SuppressResourceLoad;
|
||||
|
||||
impl SuppressResourceLoad {
|
||||
pub fn new() -> Self {
|
||||
IS_SUPPRESSING_RESOURCE_LOAD.store(true, Ordering::Relaxed);
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SuppressResourceLoad {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for SuppressResourceLoad {
|
||||
fn drop(&mut self) {
|
||||
IS_SUPPRESSING_RESOURCE_LOAD.store(false, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
use std::{future::IntoFuture, ops::Deref, panic::Location};
|
||||
|
||||
pub struct ArcResource<T, Ser = JsonSerdeCodec> {
|
||||
ser: PhantomData<Ser>,
|
||||
@@ -144,14 +116,7 @@ where
|
||||
let source = source.clone();
|
||||
move || {
|
||||
let (_, source) = source.get();
|
||||
let fut = fetcher(source);
|
||||
async move {
|
||||
if IS_SUPPRESSING_RESOURCE_LOAD.load(Ordering::Relaxed) {
|
||||
pending().await
|
||||
} else {
|
||||
fut.await
|
||||
}
|
||||
}
|
||||
fetcher(source)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ where
|
||||
Fal: Render + 'static,
|
||||
{
|
||||
#[allow(clippy::type_complexity)]
|
||||
view: <EitherOf3<(), Fal, <Defs::Match as MatchInterface>::View> as Render>::State,
|
||||
view: <EitherOf3<(), Fal, OwnedView<<Defs::Match as MatchInterface>::View>> as Render>::State,
|
||||
id: Option<RouteMatchId>,
|
||||
owner: Owner,
|
||||
params: ArcRwSignal<ParamsMap>,
|
||||
@@ -147,7 +147,7 @@ where
|
||||
provide_context(params_memo);
|
||||
provide_context(url);
|
||||
provide_context(Matched(ArcMemo::from(matched)));
|
||||
view.choose().await
|
||||
OwnedView::new(view.choose().await)
|
||||
}
|
||||
})
|
||||
}));
|
||||
@@ -292,7 +292,7 @@ where
|
||||
provide_context(Matched(ArcMemo::from(
|
||||
new_matched,
|
||||
)));
|
||||
let view =
|
||||
let view = OwnedView::new(
|
||||
if let Some(set_is_routing) = set_is_routing {
|
||||
set_is_routing.set(true);
|
||||
let value =
|
||||
@@ -302,7 +302,8 @@ where
|
||||
value
|
||||
} else {
|
||||
view.choose().await
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
// only update the route if it's still the current path
|
||||
// i.e., if we've navigated away before this has loaded, do nothing
|
||||
@@ -572,7 +573,7 @@ where
|
||||
provide_context(params_memo);
|
||||
provide_context(url);
|
||||
provide_context(Matched(ArcMemo::from(matched)));
|
||||
view.choose().await
|
||||
OwnedView::new(view.choose().await)
|
||||
}
|
||||
})
|
||||
}));
|
||||
|
||||
@@ -224,7 +224,6 @@ impl RouteList {
|
||||
where
|
||||
T: RenderHtml,
|
||||
{
|
||||
let _resource_guard = leptos::server::SuppressResourceLoad::new();
|
||||
Self::IS_GENERATING.set(true);
|
||||
// run the app once, but throw away the HTML
|
||||
// the router won't actually route, but will fill the listing
|
||||
|
||||
Reference in New Issue
Block a user