mirror of
https://github.com/leptos-rs/leptos
synced 2024-09-20 06:21:57 +00:00
fix: constrain reactive rendering to Fn(), because using dry_resolve() for Suspense requires idempotent render functions so that they can be called once (to register resources) and called a second time to resolve
This commit is contained in:
parent
5d9bd8f913
commit
e0f98dc0fd
30 changed files with 88 additions and 102 deletions
|
@ -53,7 +53,7 @@ impl<T: IntoView> RenderHtml<Dom> for View<T> {
|
||||||
self.0.resolve().await
|
self.0.resolve().await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
self.0.dry_resolve();
|
self.0.dry_resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ mod view_implementations {
|
||||||
R: Renderer,
|
R: Renderer,
|
||||||
{
|
{
|
||||||
type Output<SomeNewAttr: Attribute<R>> = Box<
|
type Output<SomeNewAttr: Attribute<R>> = Box<
|
||||||
dyn FnMut() -> Suspend<
|
dyn Fn() -> Suspend<
|
||||||
Pin<
|
Pin<
|
||||||
Box<
|
Box<
|
||||||
dyn Future<
|
dyn Future<
|
||||||
|
@ -203,7 +203,7 @@ mod view_implementations {
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
self.read();
|
self.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ impl RenderHtml<Dom> for BodyView {
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
|
|
@ -139,7 +139,7 @@ impl RenderHtml<Dom> for HtmlView {
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
|
|
@ -383,7 +383,7 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
self.el.dry_resolve()
|
self.el.dry_resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ impl RenderHtml<Dom> for MetaTagsView {
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
|
|
@ -239,7 +239,7 @@ impl RenderHtml<Dom> for TitleView {
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
|
|
@ -476,7 +476,7 @@ where
|
||||||
<Defs::Match as MatchInterface<R>>::View,
|
<Defs::Match as MatchInterface<R>>::View,
|
||||||
> as RenderHtml<R>>::MIN_LENGTH;
|
> as RenderHtml<R>>::MIN_LENGTH;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
|
|
@ -229,7 +229,7 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0; // TODO
|
const MIN_LENGTH: usize = 0; // TODO
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
|
|
@ -224,7 +224,7 @@ where
|
||||||
+ E::TAG.len()
|
+ E::TAG.len()
|
||||||
};
|
};
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
self.children.dry_resolve()
|
self.children.dry_resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ where
|
||||||
+ "data-component".len()
|
+ "data-component".len()
|
||||||
+ View::MIN_LENGTH;
|
+ View::MIN_LENGTH;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
self.view.dry_resolve()
|
self.view.dry_resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ where
|
||||||
+ "</>".len()
|
+ "</>".len()
|
||||||
+ View::MIN_LENGTH;
|
+ View::MIN_LENGTH;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
self.view.dry_resolve()
|
self.view.dry_resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = "<!DOCTYPE html>".len();
|
const MIN_LENGTH: usize = "<!DOCTYPE html>".len();
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
|
|
@ -40,7 +40,7 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
|
|
@ -22,15 +22,12 @@ where
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_html(mut self, class: &mut String) {
|
fn to_html(self, class: &mut String) {
|
||||||
let value = self.invoke();
|
let value = self.invoke();
|
||||||
value.to_html(class);
|
value.to_html(class);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hydrate<const FROM_SERVER: bool>(
|
fn hydrate<const FROM_SERVER: bool>(self, el: &R::Element) -> Self::State {
|
||||||
mut self,
|
|
||||||
el: &R::Element,
|
|
||||||
) -> Self::State {
|
|
||||||
// TODO FROM_SERVER vs template
|
// TODO FROM_SERVER vs template
|
||||||
let el = el.clone();
|
let el = el.clone();
|
||||||
RenderEffect::new(move |prev| {
|
RenderEffect::new(move |prev| {
|
||||||
|
@ -45,7 +42,7 @@ where
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(mut self, el: &R::Element) -> Self::State {
|
fn build(self, el: &R::Element) -> Self::State {
|
||||||
let el = el.to_owned();
|
let el = el.to_owned();
|
||||||
RenderEffect::new(move |prev| {
|
RenderEffect::new(move |prev| {
|
||||||
let value = self.invoke();
|
let value = self.invoke();
|
||||||
|
@ -59,7 +56,7 @@ where
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rebuild(mut self, state: &mut Self::State) {
|
fn rebuild(self, state: &mut Self::State) {
|
||||||
let prev_effect = std::mem::take(&mut state.0);
|
let prev_effect = std::mem::take(&mut state.0);
|
||||||
let prev_value = prev_effect.as_ref().and_then(|e| e.take_value());
|
let prev_value = prev_effect.as_ref().and_then(|e| e.take_value());
|
||||||
drop(prev_effect);
|
drop(prev_effect);
|
||||||
|
@ -102,7 +99,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_html(self, class: &mut String) {
|
fn to_html(self, class: &mut String) {
|
||||||
let (name, mut f) = self;
|
let (name, f) = self;
|
||||||
let include = *f.invoke().borrow();
|
let include = *f.invoke().borrow();
|
||||||
if include {
|
if include {
|
||||||
<&str as IntoClass<R>>::to_html(name, class);
|
<&str as IntoClass<R>>::to_html(name, class);
|
||||||
|
@ -111,7 +108,7 @@ where
|
||||||
|
|
||||||
fn hydrate<const FROM_SERVER: bool>(self, el: &R::Element) -> Self::State {
|
fn hydrate<const FROM_SERVER: bool>(self, el: &R::Element) -> Self::State {
|
||||||
// TODO FROM_SERVER vs template
|
// TODO FROM_SERVER vs template
|
||||||
let (name, mut f) = self;
|
let (name, f) = self;
|
||||||
let class_list = R::class_list(el);
|
let class_list = R::class_list(el);
|
||||||
let name = R::intern(name);
|
let name = R::intern(name);
|
||||||
|
|
||||||
|
@ -132,7 +129,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(self, el: &R::Element) -> Self::State {
|
fn build(self, el: &R::Element) -> Self::State {
|
||||||
let (name, mut f) = self;
|
let (name, f) = self;
|
||||||
let class_list = R::class_list(el);
|
let class_list = R::class_list(el);
|
||||||
let name = R::intern(name);
|
let name = R::intern(name);
|
||||||
|
|
||||||
|
@ -187,7 +184,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_html(self, class: &mut String) {
|
fn to_html(self, class: &mut String) {
|
||||||
let (names, mut f) = self;
|
let (names, f) = self;
|
||||||
let include = *f.invoke().borrow();
|
let include = *f.invoke().borrow();
|
||||||
if include {
|
if include {
|
||||||
for name in names {
|
for name in names {
|
||||||
|
@ -198,7 +195,7 @@ where
|
||||||
|
|
||||||
fn hydrate<const FROM_SERVER: bool>(self, el: &R::Element) -> Self::State {
|
fn hydrate<const FROM_SERVER: bool>(self, el: &R::Element) -> Self::State {
|
||||||
// TODO FROM_SERVER vs template
|
// TODO FROM_SERVER vs template
|
||||||
let (names, mut f) = self;
|
let (names, f) = self;
|
||||||
let class_list = R::class_list(el);
|
let class_list = R::class_list(el);
|
||||||
|
|
||||||
RenderEffect::new(move |prev: Option<(R::ClassList, bool)>| {
|
RenderEffect::new(move |prev: Option<(R::ClassList, bool)>| {
|
||||||
|
@ -223,7 +220,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(self, el: &R::Element) -> Self::State {
|
fn build(self, el: &R::Element) -> Self::State {
|
||||||
let (names, mut f) = self;
|
let (names, f) = self;
|
||||||
let class_list = R::class_list(el);
|
let class_list = R::class_list(el);
|
||||||
|
|
||||||
RenderEffect::new(move |prev: Option<(R::ClassList, bool)>| {
|
RenderEffect::new(move |prev: Option<(R::ClassList, bool)>| {
|
||||||
|
|
|
@ -20,7 +20,7 @@ where
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_html(mut self, buf: &mut String) {
|
fn to_html(self, buf: &mut String) {
|
||||||
let value = self.invoke();
|
let value = self.invoke();
|
||||||
value.to_html(buf);
|
value.to_html(buf);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ where
|
||||||
fn to_template(_buf: &mut String) {}
|
fn to_template(_buf: &mut String) {}
|
||||||
|
|
||||||
fn hydrate<const FROM_SERVER: bool>(
|
fn hydrate<const FROM_SERVER: bool>(
|
||||||
mut self,
|
self,
|
||||||
el: &<R as Renderer>::Element,
|
el: &<R as Renderer>::Element,
|
||||||
) -> Self::State {
|
) -> Self::State {
|
||||||
let el = el.to_owned();
|
let el = el.to_owned();
|
||||||
|
@ -43,7 +43,7 @@ where
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(mut self, el: &<R as Renderer>::Element) -> Self::State {
|
fn build(self, el: &<R as Renderer>::Element) -> Self::State {
|
||||||
let el = el.to_owned();
|
let el = el.to_owned();
|
||||||
RenderEffect::new(move |prev| {
|
RenderEffect::new(move |prev| {
|
||||||
let value = self.invoke();
|
let value = self.invoke();
|
||||||
|
|
|
@ -51,7 +51,7 @@ where
|
||||||
type State = RenderEffectState<V::State>;
|
type State = RenderEffectState<V::State>;
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn build(mut self) -> Self::State {
|
fn build(self) -> Self::State {
|
||||||
RenderEffect::new(move |prev| {
|
RenderEffect::new(move |prev| {
|
||||||
let value = self.invoke();
|
let value = self.invoke();
|
||||||
if let Some(mut state) = prev {
|
if let Some(mut state) = prev {
|
||||||
|
@ -157,11 +157,11 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
self.invoke().dry_resolve();
|
self.invoke().dry_resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn resolve(mut self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self.invoke().resolve().await
|
self.invoke().resolve().await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,13 +169,13 @@ where
|
||||||
V::MIN_LENGTH
|
V::MIN_LENGTH
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_html_with_buf(mut self, buf: &mut String, position: &mut Position) {
|
fn to_html_with_buf(self, buf: &mut String, position: &mut Position) {
|
||||||
let value = self.invoke();
|
let value = self.invoke();
|
||||||
value.to_html_with_buf(buf, position)
|
value.to_html_with_buf(buf, position)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_html_async_with_buf<const OUT_OF_ORDER: bool>(
|
fn to_html_async_with_buf<const OUT_OF_ORDER: bool>(
|
||||||
mut self,
|
self,
|
||||||
buf: &mut StreamBuilder,
|
buf: &mut StreamBuilder,
|
||||||
position: &mut Position,
|
position: &mut Position,
|
||||||
) where
|
) where
|
||||||
|
@ -186,7 +186,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hydrate<const FROM_SERVER: bool>(
|
fn hydrate<const FROM_SERVER: bool>(
|
||||||
mut self,
|
self,
|
||||||
cursor: &Cursor<R>,
|
cursor: &Cursor<R>,
|
||||||
position: &PositionState,
|
position: &PositionState,
|
||||||
) -> Self::State {
|
) -> Self::State {
|
||||||
|
@ -212,10 +212,10 @@ where
|
||||||
R: Renderer + 'static,
|
R: Renderer + 'static,
|
||||||
{
|
{
|
||||||
type Output<SomeNewAttr: Attribute<R>> =
|
type Output<SomeNewAttr: Attribute<R>> =
|
||||||
Box<dyn FnMut() -> V::Output<SomeNewAttr::CloneableOwned> + Send>;
|
Box<dyn Fn() -> V::Output<SomeNewAttr::CloneableOwned> + Send>;
|
||||||
|
|
||||||
fn add_any_attr<NewAttr: Attribute<R>>(
|
fn add_any_attr<NewAttr: Attribute<R>>(
|
||||||
mut self,
|
self,
|
||||||
attr: NewAttr,
|
attr: NewAttr,
|
||||||
) -> Self::Output<NewAttr>
|
) -> Self::Output<NewAttr>
|
||||||
where
|
where
|
||||||
|
@ -305,7 +305,7 @@ where
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_html(mut self, key: &str, buf: &mut String) {
|
fn to_html(self, key: &str, buf: &mut String) {
|
||||||
let value = self.invoke();
|
let value = self.invoke();
|
||||||
value.to_html(key, buf);
|
value.to_html(key, buf);
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ where
|
||||||
fn to_template(_key: &str, _buf: &mut String) {}
|
fn to_template(_key: &str, _buf: &mut String) {}
|
||||||
|
|
||||||
fn hydrate<const FROM_SERVER: bool>(
|
fn hydrate<const FROM_SERVER: bool>(
|
||||||
mut self,
|
self,
|
||||||
key: &str,
|
key: &str,
|
||||||
el: &<R as Renderer>::Element,
|
el: &<R as Renderer>::Element,
|
||||||
) -> Self::State {
|
) -> Self::State {
|
||||||
|
@ -333,11 +333,7 @@ where
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(
|
fn build(self, el: &<R as Renderer>::Element, key: &str) -> Self::State {
|
||||||
mut self,
|
|
||||||
el: &<R as Renderer>::Element,
|
|
||||||
key: &str,
|
|
||||||
) -> Self::State {
|
|
||||||
let key = R::intern(key);
|
let key = R::intern(key);
|
||||||
let key = key.to_owned();
|
let key = key.to_owned();
|
||||||
let el = el.to_owned();
|
let el = el.to_owned();
|
||||||
|
@ -367,40 +363,40 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type SharedReactiveFunction<T> = Arc<Mutex<dyn FnMut() -> T + Send>>;
|
pub type SharedReactiveFunction<T> = Arc<Mutex<dyn Fn() -> T + Send>>;
|
||||||
|
|
||||||
pub trait ReactiveFunction: Send + 'static {
|
pub trait ReactiveFunction: Send + 'static {
|
||||||
type Output;
|
type Output;
|
||||||
|
|
||||||
fn invoke(&mut self) -> Self::Output;
|
fn invoke(&self) -> Self::Output;
|
||||||
|
|
||||||
fn into_shared(self) -> Arc<Mutex<dyn FnMut() -> Self::Output + Send>>;
|
fn into_shared(self) -> Arc<Mutex<dyn Fn() -> Self::Output + Send>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: 'static> ReactiveFunction for Arc<Mutex<dyn FnMut() -> T + Send>> {
|
impl<T: 'static> ReactiveFunction for Arc<Mutex<dyn Fn() -> T + Send>> {
|
||||||
type Output = T;
|
type Output = T;
|
||||||
|
|
||||||
fn invoke(&mut self) -> Self::Output {
|
fn invoke(&self) -> Self::Output {
|
||||||
let mut fun = self.lock().expect("lock poisoned");
|
let fun = self.lock().expect("lock poisoned");
|
||||||
fun()
|
fun()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn into_shared(self) -> Arc<Mutex<dyn FnMut() -> Self::Output + Send>> {
|
fn into_shared(self) -> Arc<Mutex<dyn Fn() -> Self::Output + Send>> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, T> ReactiveFunction for F
|
impl<F, T> ReactiveFunction for F
|
||||||
where
|
where
|
||||||
F: FnMut() -> T + Send + 'static,
|
F: Fn() -> T + Send + 'static,
|
||||||
{
|
{
|
||||||
type Output = T;
|
type Output = T;
|
||||||
|
|
||||||
fn invoke(&mut self) -> Self::Output {
|
fn invoke(&self) -> Self::Output {
|
||||||
self()
|
self()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn into_shared(self) -> Arc<Mutex<dyn FnMut() -> Self::Output + Send>> {
|
fn into_shared(self) -> Arc<Mutex<dyn Fn() -> Self::Output + Send>> {
|
||||||
Arc::new(Mutex::new(self))
|
Arc::new(Mutex::new(self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,7 +472,7 @@ mod stable {
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
@ -620,7 +616,7 @@ mod stable {
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
|
|
@ -157,7 +157,7 @@ where
|
||||||
OwnedView { owner, view, rndr }
|
OwnedView { owner, view, rndr }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
self.owner.with(|| self.view.dry_resolve());
|
self.owner.with(|| self.view.dry_resolve());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ where
|
||||||
type CloneableOwned = SharedReactiveFunction<V>;
|
type CloneableOwned = SharedReactiveFunction<V>;
|
||||||
|
|
||||||
fn hydrate<const FROM_SERVER: bool>(
|
fn hydrate<const FROM_SERVER: bool>(
|
||||||
mut self,
|
self,
|
||||||
el: &<R as Renderer>::Element,
|
el: &<R as Renderer>::Element,
|
||||||
key: &str,
|
key: &str,
|
||||||
) -> Self::State {
|
) -> Self::State {
|
||||||
|
@ -37,11 +37,7 @@ where
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(
|
fn build(self, el: &<R as Renderer>::Element, key: &str) -> Self::State {
|
||||||
mut self,
|
|
||||||
el: &<R as Renderer>::Element,
|
|
||||||
key: &str,
|
|
||||||
) -> Self::State {
|
|
||||||
let key = R::intern(key);
|
let key = R::intern(key);
|
||||||
let key = key.to_owned();
|
let key = key.to_owned();
|
||||||
let el = el.to_owned();
|
let el = el.to_owned();
|
||||||
|
|
|
@ -14,7 +14,7 @@ where
|
||||||
type CloneableOwned = (&'static str, SharedReactiveFunction<S>);
|
type CloneableOwned = (&'static str, SharedReactiveFunction<S>);
|
||||||
|
|
||||||
fn to_html(self, style: &mut String) {
|
fn to_html(self, style: &mut String) {
|
||||||
let (name, mut f) = self;
|
let (name, f) = self;
|
||||||
let value = f.invoke();
|
let value = f.invoke();
|
||||||
style.push_str(name);
|
style.push_str(name);
|
||||||
style.push(':');
|
style.push(':');
|
||||||
|
@ -23,7 +23,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hydrate<const FROM_SERVER: bool>(self, el: &R::Element) -> Self::State {
|
fn hydrate<const FROM_SERVER: bool>(self, el: &R::Element) -> Self::State {
|
||||||
let (name, mut f) = self;
|
let (name, f) = self;
|
||||||
let name = R::intern(name);
|
let name = R::intern(name);
|
||||||
// TODO FROM_SERVER vs template
|
// TODO FROM_SERVER vs template
|
||||||
let style = R::style(el);
|
let style = R::style(el);
|
||||||
|
@ -51,7 +51,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(self, el: &R::Element) -> Self::State {
|
fn build(self, el: &R::Element) -> Self::State {
|
||||||
let (name, mut f) = self;
|
let (name, f) = self;
|
||||||
let name = R::intern(name);
|
let name = R::intern(name);
|
||||||
let style = R::style(el);
|
let style = R::style(el);
|
||||||
RenderEffect::new(move |prev| {
|
RenderEffect::new(move |prev| {
|
||||||
|
@ -98,15 +98,12 @@ where
|
||||||
type Cloneable = SharedReactiveFunction<C>;
|
type Cloneable = SharedReactiveFunction<C>;
|
||||||
type CloneableOwned = SharedReactiveFunction<C>;
|
type CloneableOwned = SharedReactiveFunction<C>;
|
||||||
|
|
||||||
fn to_html(mut self, style: &mut String) {
|
fn to_html(self, style: &mut String) {
|
||||||
let value = self.invoke();
|
let value = self.invoke();
|
||||||
value.to_html(style);
|
value.to_html(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hydrate<const FROM_SERVER: bool>(
|
fn hydrate<const FROM_SERVER: bool>(self, el: &R::Element) -> Self::State {
|
||||||
mut self,
|
|
||||||
el: &R::Element,
|
|
||||||
) -> Self::State {
|
|
||||||
// TODO FROM_SERVER vs template
|
// TODO FROM_SERVER vs template
|
||||||
let el = el.clone();
|
let el = el.clone();
|
||||||
RenderEffect::new(move |prev| {
|
RenderEffect::new(move |prev| {
|
||||||
|
@ -120,7 +117,7 @@ where
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(mut self, el: &R::Element) -> Self::State {
|
fn build(self, el: &R::Element) -> Self::State {
|
||||||
let el = el.clone();
|
let el = el.clone();
|
||||||
RenderEffect::new(move |prev| {
|
RenderEffect::new(move |prev| {
|
||||||
let value = self.invoke();
|
let value = self.invoke();
|
||||||
|
|
|
@ -225,5 +225,5 @@ where
|
||||||
Some(self.0.await)
|
Some(self.0.await)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ where
|
||||||
resolve:
|
resolve:
|
||||||
fn(Box<dyn Any>) -> Pin<Box<dyn Future<Output = AnyView<R>> + Send>>,
|
fn(Box<dyn Any>) -> Pin<Box<dyn Future<Output = AnyView<R>> + Send>>,
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
dry_resolve: fn(&mut Box<dyn Any + Send>),
|
dry_resolve: fn(&Box<dyn Any + Send>),
|
||||||
#[cfg(feature = "hydrate")]
|
#[cfg(feature = "hydrate")]
|
||||||
#[cfg(feature = "hydrate")]
|
#[cfg(feature = "hydrate")]
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
|
@ -144,10 +144,10 @@ where
|
||||||
let value = Box::new(self) as Box<dyn Any + Send>;
|
let value = Box::new(self) as Box<dyn Any + Send>;
|
||||||
|
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
let dry_resolve = |value: &mut Box<dyn Any + Send>| {
|
let dry_resolve = |value: &Box<dyn Any + Send>| {
|
||||||
let value = value
|
let value = value
|
||||||
.downcast_mut::<T>()
|
.downcast_ref::<T>()
|
||||||
.expect("AnyView::resolve could not be downcast");
|
.expect("AnyView::dry_resolve could not be downcast");
|
||||||
value.dry_resolve();
|
value.dry_resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -304,10 +304,10 @@ where
|
||||||
{
|
{
|
||||||
type AsyncOutput = Self;
|
type AsyncOutput = Self;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
{
|
{
|
||||||
(self.dry_resolve)(&mut self.value)
|
(self.dry_resolve)(&self.value)
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "ssr"))]
|
#[cfg(not(feature = "ssr"))]
|
||||||
panic!(
|
panic!(
|
||||||
|
|
|
@ -149,7 +149,7 @@ where
|
||||||
{
|
{
|
||||||
type AsyncOutput = Either<A::AsyncOutput, B::AsyncOutput>;
|
type AsyncOutput = Either<A::AsyncOutput, B::AsyncOutput>;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
match self {
|
match self {
|
||||||
Either::Left(left) => left.dry_resolve(),
|
Either::Left(left) => left.dry_resolve(),
|
||||||
Either::Right(right) => right.dry_resolve(),
|
Either::Right(right) => right.dry_resolve(),
|
||||||
|
@ -337,7 +337,7 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ macro_rules! tuples {
|
||||||
const MIN_LENGTH: usize = max_usize(&[$($ty ::MIN_LENGTH,)*]);
|
const MIN_LENGTH: usize = max_usize(&[$($ty ::MIN_LENGTH,)*]);
|
||||||
|
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
match self {
|
match self {
|
||||||
$([<EitherOf $num>]::$ty(this) => {
|
$([<EitherOf $num>]::$ty(this) => {
|
||||||
this.dry_resolve();
|
this.dry_resolve();
|
||||||
|
|
|
@ -143,8 +143,8 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = T::MIN_LENGTH;
|
const MIN_LENGTH: usize = T::MIN_LENGTH;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
if let Ok(inner) = self.as_mut() {
|
if let Ok(inner) = self.as_ref() {
|
||||||
inner.dry_resolve()
|
inner.dry_resolve()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,8 +73,8 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = T::MIN_LENGTH;
|
const MIN_LENGTH: usize = T::MIN_LENGTH;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
if let Some(inner) = self.as_mut() {
|
if let Some(inner) = self.as_ref() {
|
||||||
inner.dry_resolve();
|
inner.dry_resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,8 +313,8 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
for inner in self.iter_mut() {
|
for inner in self {
|
||||||
inner.dry_resolve();
|
inner.dry_resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
// TODO...
|
// TODO...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize;
|
const MIN_LENGTH: usize;
|
||||||
|
|
||||||
fn dry_resolve(&mut self);
|
fn dry_resolve(&self);
|
||||||
|
|
||||||
/// Waits for any asynchronous sections of the view to load and returns the output.
|
/// Waits for any asynchronous sections of the view to load and returns the output.
|
||||||
fn resolve(self) -> impl Future<Output = Self::AsyncOutput> + Send;
|
fn resolve(self) -> impl Future<Output = Self::AsyncOutput> + Send;
|
||||||
|
|
|
@ -73,7 +73,7 @@ macro_rules! render_primitive {
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
|
|
@ -166,7 +166,7 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = V.len();
|
const MIN_LENGTH: usize = V.len();
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
// this won't actually compile because if a weird interaction because the const &'static str and
|
// this won't actually compile because if a weird interaction because the const &'static str and
|
||||||
// the RPITIT, so we just refine it to a concrete future type; this will never change in any
|
// the RPITIT, so we just refine it to a concrete future type; this will never change in any
|
||||||
|
|
|
@ -43,7 +43,7 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
@ -168,7 +168,7 @@ where
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
type AsyncOutput = Self;
|
type AsyncOutput = Self;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
@ -358,7 +358,7 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
@ -453,7 +453,7 @@ where
|
||||||
|
|
||||||
const MIN_LENGTH: usize = 0;
|
const MIN_LENGTH: usize = 0;
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {
|
async fn resolve(self) -> Self::AsyncOutput {
|
||||||
self
|
self
|
||||||
|
|
|
@ -92,7 +92,7 @@ where
|
||||||
self.view.hydrate::<FROM_SERVER>(cursor, position)
|
self.view.hydrate::<FROM_SERVER>(cursor, position)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ where
|
||||||
|
|
||||||
async fn resolve(self) -> Self::AsyncOutput {}
|
async fn resolve(self) -> Self::AsyncOutput {}
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {}
|
fn dry_resolve(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Rndr> AddAnyAttr<Rndr> for ()
|
impl<Rndr> AddAnyAttr<Rndr> for ()
|
||||||
|
@ -136,7 +136,7 @@ where
|
||||||
(self.0.resolve().await,)
|
(self.0.resolve().await,)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
self.0.dry_resolve();
|
self.0.dry_resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ macro_rules! impl_view_for_tuples {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dry_resolve(&mut self) {
|
fn dry_resolve(&self) {
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
let ($first, $($ty,)*) = self;
|
let ($first, $($ty,)*) = self;
|
||||||
$first.dry_resolve();
|
$first.dry_resolve();
|
||||||
|
|
Loading…
Reference in a new issue