Feat: clean up code
This commit is contained in:
1 parent
5204862bc2
commit
83451372aa
16 files changed
+67
-72
No files matched your search
@@ -1,10 +1,10 @@
|
|||||||
//! An alternative function syntax
|
//! An alternative function syntax
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use dioxus_core::prelude::{DomTree, VNode};
|
use dioxus_core::prelude::{VNode};
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ struct Context2<'a, P> {
|
|||||||
rops: &'a P, // _p: PhantomData<&'a ()>,
|
rops: &'a P, // _p: PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
impl<'a, P> Context2<'a, P> {
|
impl<'a, P> Context2<'a, P> {
|
||||||
fn view(self, f: impl FnOnce(&'a Bump) -> VNode<'a>) -> DTree {
|
fn view(self, _f: impl FnOnce(&'a Bump) -> VNode<'a>) -> DTree {
|
||||||
DTree {}
|
DTree {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,9 +23,9 @@ impl<'a, P> Context2<'a, P> {
|
|||||||
|
|
||||||
pub fn use_hook<'scope, InternalHookState: 'static, Output: 'a>(
|
pub fn use_hook<'scope, InternalHookState: 'static, Output: 'a>(
|
||||||
&'scope self,
|
&'scope self,
|
||||||
initializer: impl FnOnce() -> InternalHookState,
|
_initializer: impl FnOnce() -> InternalHookState,
|
||||||
runner: impl FnOnce(&'a mut InternalHookState) -> Output,
|
_runner: impl FnOnce(&'a mut InternalHookState) -> Output,
|
||||||
cleanup: impl FnOnce(InternalHookState),
|
_cleanup: impl FnOnce(InternalHookState),
|
||||||
) -> Output {
|
) -> Output {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ trait Properties {}
|
|||||||
|
|
||||||
struct DTree;
|
struct DTree;
|
||||||
// type FC2<'a, T: 'a> = fn(Context2<T>) -> DTree;
|
// type FC2<'a, T: 'a> = fn(Context2<T>) -> DTree;
|
||||||
fn virtual_child<'a, T: 'a>(bump: &'a Bump, props: T, f: FC2<T>) -> VNode<'a> {
|
fn virtual_child<'a, T: 'a>(_bump: &'a Bump, _props: T, _f: FC2<T>) -> VNode<'a> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ fn Example(ctx: Context2<Props>) -> DTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// #[fc]
|
// #[fc]
|
||||||
fn Example2(ctx: Context2<()>, name: &str, blah: &str) -> DTree {
|
fn Example2(ctx: Context2<()>, name: &str, _blah: &str) -> DTree {
|
||||||
let val = use_state(&ctx, || String::from("asd"));
|
let val = use_state(&ctx, || String::from("asd"));
|
||||||
|
|
||||||
ctx.view(move |b| {
|
ctx.view(move |b| {
|
||||||
@@ -67,10 +67,10 @@ fn Example2(ctx: Context2<()>, name: &str, blah: &str) -> DTree {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type FC2<'a, T: 'a> = fn(Context2<T>) -> DTree;
|
type FC2<'a, T> = fn(Context2<T>) -> DTree;
|
||||||
|
|
||||||
// still works if you don't take any references in your props (ie, something copy or cloneable)
|
// still works if you don't take any references in your props (ie, something copy or cloneable)
|
||||||
static CHILD: FC2<Props2> = |ctx: Context2<Props2>| {
|
static CHILD: FC2<Props2> = |_ctx: Context2<Props2>| {
|
||||||
//
|
//
|
||||||
todo!()
|
todo!()
|
||||||
};
|
};
|
||||||
@@ -81,15 +81,15 @@ struct Props2<'a> {
|
|||||||
impl Properties for Props2<'_> {}
|
impl Properties for Props2<'_> {}
|
||||||
|
|
||||||
fn AltChild(ctx: Context2<Props2>) -> DTree {
|
fn AltChild(ctx: Context2<Props2>) -> DTree {
|
||||||
ctx.view(|b| {
|
ctx.view(|_b| {
|
||||||
//
|
//
|
||||||
todo!()
|
todo!()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn use_state<'a, 'c, P, T: 'static, F: FnOnce() -> T>(
|
fn use_state<'a, 'c, P, T: 'static, F: FnOnce() -> T>(
|
||||||
ctx: &'_ Context2<'a, P>,
|
_ctx: &'_ Context2<'a, P>,
|
||||||
initial_state_fn: F,
|
_initial_state_fn: F,
|
||||||
) -> (&'a T) {
|
) -> &'a T {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@@ -38,6 +38,6 @@ struct ChildProps<'a> {
|
|||||||
item: &'a ListItem,
|
item: &'a ListItem,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn child_item(ctx: Context, props: &ChildProps) -> DomTree {
|
fn child_item(_ctx: Context, _props: &ChildProps) -> DomTree {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{borrow::Borrow, marker::PhantomData, ops::Deref};
|
|
||||||
|
|
||||||
use builder::{button, div};
|
|
||||||
|
use builder::{button};
|
||||||
use dioxus_core::prelude::*;
|
use dioxus_core::prelude::*;
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
// use dioxus_core::prelude::VNode;
|
// use dioxus_core::prelude::VNode;
|
||||||
// use dioxus_core::prelude::*;
|
// use dioxus_core::prelude::*;
|
||||||
// use once_cell::sync::{Lazy, OnceCell};
|
// use once_cell::sync::{Lazy, OnceCell};
|
||||||
use std::{collections::HashMap, future::Future, marker::PhantomData};
|
|
||||||
|
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
@@ -49,14 +49,14 @@ struct Context<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Context<'a> {
|
impl<'a> Context<'a> {
|
||||||
fn use_context<'b, I, O: 'b>(&self, f: fn(&'b I) -> O) -> ContextGuard2<O> {
|
fn use_context<'b, I, O: 'b>(&self, _f: fn(&'b I) -> O) -> ContextGuard2<O> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
fn add_listener(&self, f: impl Fn(()) + 'a) {
|
fn add_listener(&self, _f: impl Fn(()) + 'a) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view(self, f: impl FnOnce(&'a String) + 'a) {}
|
fn view(self, _f: impl FnOnce(&'a String) + 'a) {}
|
||||||
// fn view(self, f: impl for<'b> FnOnce(&'a String) + 'a) {}
|
// fn view(self, f: impl for<'b> FnOnce(&'a String) + 'a) {}
|
||||||
// fn view(self, f: impl for<'b> FnOnce(&'b String) + 'a) {}
|
// fn view(self, f: impl for<'b> FnOnce(&'b String) + 'a) {}
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ fn t<'a>(ctx: Context<'a>) {
|
|||||||
|
|
||||||
ctx.add_listener(move |_| {
|
ctx.add_listener(move |_| {
|
||||||
// let val = value.get().as_str();
|
// let val = value.get().as_str();
|
||||||
let val2 = r2.as_bytes();
|
let _val2 = r2.as_bytes();
|
||||||
println!("v2 is {}", r2);
|
println!("v2 is {}", r2);
|
||||||
// println!("refed is {}", refed);
|
// println!("refed is {}", refed);
|
||||||
});
|
});
|
||||||
@@ -97,7 +97,7 @@ fn t<'a>(ctx: Context<'a>) {
|
|||||||
// let val2 = refed.as_bytes();
|
// let val2 = refed.as_bytes();
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.view(move |b| {});
|
ctx.view(move |_b| {});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
@@ -25,7 +25,7 @@ struct OutputNode<'a> {
|
|||||||
// everything is managed at runtime because that's how we make something ergonomc
|
// everything is managed at runtime because that's how we make something ergonomc
|
||||||
// lifetime management in dioxus is just cheating around the rules
|
// lifetime management in dioxus is just cheating around the rules
|
||||||
// our kind god manages lifetimes for us so we don't have to, thanks god
|
// our kind god manages lifetimes for us so we don't have to, thanks god
|
||||||
fn something<'s>(props: &'s SomeProps<'s>) -> OutputNode<'s> {
|
fn something<'s>(_props: &'s SomeProps<'s>) -> OutputNode<'s> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use dioxus_core::prelude::*;
|
|||||||
fn main() -> Result<(), ()> {
|
fn main() -> Result<(), ()> {
|
||||||
let p1 = Props { name: "bob".into() };
|
let p1 = Props { name: "bob".into() };
|
||||||
|
|
||||||
let mut vdom = VirtualDom::new_with_props(Example, p1);
|
let _vdom = VirtualDom::new_with_props(Example, p1);
|
||||||
// vdom.progress()?;
|
// vdom.progress()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -29,7 +29,7 @@ struct Props {
|
|||||||
// // }
|
// // }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
static Example: FC<Props> = |ctx, props| {
|
static Example: FC<Props> = |ctx, _props| {
|
||||||
ctx.view(html! {
|
ctx.view(html! {
|
||||||
<div>
|
<div>
|
||||||
<h1> "hello world!" </h1>
|
<h1> "hello world!" </h1>
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
//!
|
//!
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use std::ops::{Deref, DerefMut};
|
|
||||||
|
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
|
|
||||||
use crate::innerlude::{Listener, VirtualDom};
|
use crate::innerlude::{Listener};
|
||||||
|
|
||||||
/// The `Edit` represents a single modifcation of the renderer tree.
|
/// The `Edit` represents a single modifcation of the renderer tree.
|
||||||
///
|
///
|
||||||
@@ -73,7 +73,7 @@ pub struct EditMachine<'src> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'b> EditMachine<'b> {
|
impl<'b> EditMachine<'b> {
|
||||||
pub fn new(bump: &'b Bump) -> Self {
|
pub fn new(_bump: &'b Bump) -> Self {
|
||||||
Self {
|
Self {
|
||||||
traversal: Traversal::new(),
|
traversal: Traversal::new(),
|
||||||
next_temporary: 0,
|
next_temporary: 0,
|
||||||
@@ -206,7 +206,7 @@ impl<'a> EditMachine<'a> {
|
|||||||
self.emitter.push(Edit::InsertBefore {})
|
self.emitter.push(Edit::InsertBefore {})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ensure_string(&mut self, string: &str) -> StringKey {
|
pub fn ensure_string(&mut self, _string: &str) -> StringKey {
|
||||||
todo!()
|
todo!()
|
||||||
// self.strings.ensure_string(string, &self.emitter)
|
// self.strings.ensure_string(string, &self.emitter)
|
||||||
}
|
}
|
||||||
@@ -308,7 +308,7 @@ impl<'a> EditMachine<'a> {
|
|||||||
self.forcing_new_listeners = previous;
|
self.forcing_new_listeners = previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_event_listener(&mut self, listener: &Listener) {
|
pub fn new_event_listener(&mut self, _listener: &Listener) {
|
||||||
debug_assert!(self.traversal_is_committed());
|
debug_assert!(self.traversal_is_committed());
|
||||||
todo!("Event listener not wired up yet");
|
todo!("Event listener not wired up yet");
|
||||||
// debug!("emit: new_event_listener({:?})", listener);
|
// debug!("emit: new_event_listener({:?})", listener);
|
||||||
@@ -330,14 +330,14 @@ impl<'a> EditMachine<'a> {
|
|||||||
todo!("Event listener not wired up yet");
|
todo!("Event listener not wired up yet");
|
||||||
// let (a, b) = listener.get_callback_parts();
|
// let (a, b) = listener.get_callback_parts();
|
||||||
// debug_assert!(a != 0);
|
// debug_assert!(a != 0);
|
||||||
let event_id = self.ensure_string(listener.event);
|
let _event_id = self.ensure_string(listener.event);
|
||||||
// self.emitter.update_event_listener(event_id.into(), a, b);
|
// self.emitter.update_event_listener(event_id.into(), a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_event_listener(&mut self, event: &str) {
|
pub fn remove_event_listener(&mut self, event: &str) {
|
||||||
debug_assert!(self.traversal_is_committed());
|
debug_assert!(self.traversal_is_committed());
|
||||||
// debug!("emit: remove_event_listener({:?})", event);
|
// debug!("emit: remove_event_listener({:?})", event);
|
||||||
let event_id = self.ensure_string(event);
|
let _event_id = self.ensure_string(event);
|
||||||
todo!("Event listener not wired up yet");
|
todo!("Event listener not wired up yet");
|
||||||
// self.emitter.remove_event_listener(event_id.into());
|
// self.emitter.remove_event_listener(event_id.into());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,6 @@
|
|||||||
//! for components to be used within Nodes.
|
//! for components to be used within Nodes.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use std::fmt::Debug;
|
|
||||||
|
|
||||||
use crate::innerlude::*;
|
|
||||||
|
|
||||||
/// The `Component` trait refers to any struct or funciton that can be used as a component
|
/// The `Component` trait refers to any struct or funciton that can be used as a component
|
||||||
/// We automatically implement Component for FC<T>
|
/// We automatically implement Component for FC<T>
|
||||||
// pub trait Component {
|
// pub trait Component {
|
||||||
@@ -39,8 +35,8 @@ use crate::innerlude::*;
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use crate::prelude::bumpalo::Bump;
|
use crate::prelude::bumpalo::Bump;
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
fn test_static_fn<'a, P>(b: &'a Bump, r: FC<P>) -> VNode<'a> {
|
fn test_static_fn<'a, P>(b: &'a Bump, r: FC<P>) -> VNode<'a> {
|
||||||
todo!()
|
todo!()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{innerlude::Scope, nodes::VNode};
|
use crate::{nodes::VNode};
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use hooks::Hook;
|
use hooks::Hook;
|
||||||
use std::{
|
use std::{
|
||||||
@@ -76,18 +76,18 @@ impl<'a> Context<'a> {
|
|||||||
// pub fn view(self, lazy_nodes: impl for<'b> FnOnce(&'b Bump) -> VNode<'b> + 'a + 'p) -> DomTree {
|
// pub fn view(self, lazy_nodes: impl for<'b> FnOnce(&'b Bump) -> VNode<'b> + 'a + 'p) -> DomTree {
|
||||||
// pub fn view<'p>(self, lazy_nodes: impl FnOnce(&'a Bump) -> VNode<'a> + 'a + 'p) -> DomTree {
|
// pub fn view<'p>(self, lazy_nodes: impl FnOnce(&'a Bump) -> VNode<'a> + 'a + 'p) -> DomTree {
|
||||||
// pub fn view(self, lazy_nodes: impl FnOnce(&'a Bump) -> VNode<'a> + 'a) -> VNode<'a> {
|
// pub fn view(self, lazy_nodes: impl FnOnce(&'a Bump) -> VNode<'a> + 'a) -> VNode<'a> {
|
||||||
let g = lazy_nodes(self.bump);
|
let _g = lazy_nodes(self.bump);
|
||||||
DomTree {}
|
DomTree {}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn callback(&self, f: impl Fn(()) + 'a) {}
|
pub fn callback(&self, _f: impl Fn(()) + 'a) {}
|
||||||
|
|
||||||
/// Create a suspended component from a future.
|
/// Create a suspended component from a future.
|
||||||
///
|
///
|
||||||
/// When the future completes, the component will be renderered
|
/// When the future completes, the component will be renderered
|
||||||
pub fn suspend(
|
pub fn suspend(
|
||||||
&self,
|
&self,
|
||||||
fut: impl Future<Output = impl FnOnce(&'a Bump) -> VNode<'a>>,
|
_fut: impl Future<Output = impl FnOnce(&'a Bump) -> VNode<'a>>,
|
||||||
) -> VNode<'a> {
|
) -> VNode<'a> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ pub mod hooks {
|
|||||||
runner: impl FnOnce(&'a mut InternalHookState) -> Output,
|
runner: impl FnOnce(&'a mut InternalHookState) -> Output,
|
||||||
// The closure that cleans up whatever mess is left when the component gets torn down
|
// The closure that cleans up whatever mess is left when the component gets torn down
|
||||||
// TODO: add this to the "clean up" group for when the component is dropped
|
// TODO: add this to the "clean up" group for when the component is dropped
|
||||||
cleanup: impl FnOnce(InternalHookState),
|
_cleanup: impl FnOnce(InternalHookState),
|
||||||
) -> Output {
|
) -> Output {
|
||||||
let raw_hook = {
|
let raw_hook = {
|
||||||
let idx = self.idx.load(std::sync::atomic::Ordering::Relaxed);
|
let idx = self.idx.load(std::sync::atomic::Ordering::Relaxed);
|
||||||
@@ -186,9 +186,9 @@ mod context_api {
|
|||||||
//! a failure of implementation.
|
//! a failure of implementation.
|
||||||
//!
|
//!
|
||||||
//!
|
//!
|
||||||
use super::*;
|
|
||||||
|
|
||||||
use std::{marker::PhantomPinned, mem::swap, ops::Deref};
|
use std::{ops::Deref};
|
||||||
|
|
||||||
pub struct RemoteState<T> {
|
pub struct RemoteState<T> {
|
||||||
inner: *const T,
|
inner: *const T,
|
||||||
@@ -229,7 +229,7 @@ Context should *never* be dangling!. If a Context is torn down, so should anythi
|
|||||||
|
|
||||||
impl<'a> super::Context<'a> {
|
impl<'a> super::Context<'a> {
|
||||||
// impl<'a, P> super::Context<'a, P> {
|
// impl<'a, P> super::Context<'a, P> {
|
||||||
pub fn use_context<I, O>(&'a self, narrow: impl Fn(&'_ I) -> &'_ O) -> RemoteState<O> {
|
pub fn use_context<I, O>(&'a self, _narrow: impl Fn(&'_ I) -> &'_ O) -> RemoteState<O> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -950,7 +950,7 @@ impl<'a> DiffMachine<'a> {
|
|||||||
// When this function returns, the change list stack is in the same state.
|
// When this function returns, the change list stack is in the same state.
|
||||||
pub fn remove_all_children(&mut self, old: &[VNode<'a>]) {
|
pub fn remove_all_children(&mut self, old: &[VNode<'a>]) {
|
||||||
debug_assert!(self.change_list.traversal_is_committed());
|
debug_assert!(self.change_list.traversal_is_committed());
|
||||||
for child in old {
|
for _child in old {
|
||||||
// registry.remove_subtree(child);
|
// registry.remove_subtree(child);
|
||||||
}
|
}
|
||||||
// Fast way to remove all children: set the node's textContent to an empty
|
// Fast way to remove all children: set the node's textContent to an empty
|
||||||
@@ -984,7 +984,7 @@ impl<'a> DiffMachine<'a> {
|
|||||||
// [... parent]
|
// [... parent]
|
||||||
pub fn remove_self_and_next_siblings(&mut self, old: &[VNode<'a>]) {
|
pub fn remove_self_and_next_siblings(&mut self, old: &[VNode<'a>]) {
|
||||||
debug_assert!(self.change_list.traversal_is_committed());
|
debug_assert!(self.change_list.traversal_is_committed());
|
||||||
for child in old {
|
for _child in old {
|
||||||
// registry.remove_subtree(child);
|
// registry.remove_subtree(child);
|
||||||
}
|
}
|
||||||
self.change_list.remove_self_and_next_siblings();
|
self.change_list.remove_self_and_next_siblings();
|
||||||
@@ -1001,7 +1001,7 @@ enum KeyedPrefixResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod support {
|
mod support {
|
||||||
use super::*;
|
|
||||||
|
|
||||||
// // Get or create the template.
|
// // Get or create the template.
|
||||||
// //
|
// //
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ pub mod builder {
|
|||||||
// types used internally that are important
|
// types used internally that are important
|
||||||
pub(crate) mod innerlude {
|
pub(crate) mod innerlude {
|
||||||
// pub(crate) use crate::component::Properties;
|
// pub(crate) use crate::component::Properties;
|
||||||
use crate::context::hooks::Hook;
|
|
||||||
pub(crate) use crate::context::Context;
|
pub(crate) use crate::context::Context;
|
||||||
pub(crate) use crate::error::{Error, Result};
|
pub(crate) use crate::error::{Error, Result};
|
||||||
use crate::nodes;
|
use crate::nodes;
|
||||||
@@ -102,7 +102,7 @@ pub(crate) mod innerlude {
|
|||||||
pub type FC<P> = for<'scope> fn(Context<'scope>, &'scope P) -> DomTree;
|
pub type FC<P> = for<'scope> fn(Context<'scope>, &'scope P) -> DomTree;
|
||||||
|
|
||||||
mod fc2 {
|
mod fc2 {
|
||||||
use super::*;
|
|
||||||
}
|
}
|
||||||
// pub type FC<'a, P: 'a> = for<'scope> fn(Context<'scope>, &'scope P) -> DomTree;
|
// pub type FC<'a, P: 'a> = for<'scope> fn(Context<'scope>, &'scope P) -> DomTree;
|
||||||
// pub type FC<P> = for<'scope, 'r> fn(Context<'scope>, &'scope P) -> DomTree;
|
// pub type FC<P> = for<'scope, 'r> fn(Context<'scope>, &'scope P) -> DomTree;
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ where
|
|||||||
/// .finish();
|
/// .finish();
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn on(mut self, event: &'a str, callback: impl Fn(()) + 'a) -> Self
|
pub fn on(self, _event: &'a str, _callback: impl Fn(()) + 'a) -> Self
|
||||||
// pub fn on<F>(mut self, event: &'a str, callback: impl Fn(()) -> () + 'static) -> Self
|
// pub fn on<F>(mut self, event: &'a str, callback: impl Fn(()) -> () + 'static) -> Self
|
||||||
// F: Fn(()) + 'static,
|
// F: Fn(()) + 'static,
|
||||||
// F: Fn(()) + 'a,
|
// F: Fn(()) + 'a,
|
||||||
@@ -1081,7 +1081,7 @@ pub fn on<'a, 'b, F: 'static>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn virtual_child<'a, T>(bump: &'a Bump, props: T, f: crate::innerlude::FC<T>) -> VNode<'a> {
|
pub fn virtual_child<'a, T>(_bump: &'a Bump, _props: T, _f: crate::innerlude::FC<T>) -> VNode<'a> {
|
||||||
todo!()
|
todo!()
|
||||||
// VNode::Component()
|
// VNode::Component()
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
//!
|
//!
|
||||||
//! These VNodes should be *very* cheap and *very* fast to construct - building a full tree should be insanely quick.
|
//! These VNodes should be *very* cheap and *very* fast to construct - building a full tree should be insanely quick.
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
pub use vcomponent::VComponent;
|
pub use vcomponent::VComponent;
|
||||||
@@ -97,7 +97,7 @@ mod vnode {
|
|||||||
|
|
||||||
mod velement {
|
mod velement {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::{collections::HashMap, fmt::Debug};
|
use std::{fmt::Debug};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct VElement<'a> {
|
pub struct VElement<'a> {
|
||||||
@@ -133,7 +133,7 @@ mod velement {
|
|||||||
|
|
||||||
impl<'a> VElement<'a> {
|
impl<'a> VElement<'a> {
|
||||||
// The tag of a component MUST be known at compile time
|
// The tag of a component MUST be known at compile time
|
||||||
pub fn new(tag: &'a str) -> Self {
|
pub fn new(_tag: &'a str) -> Self {
|
||||||
todo!()
|
todo!()
|
||||||
// VElement {
|
// VElement {
|
||||||
// tag,
|
// tag,
|
||||||
@@ -265,9 +265,9 @@ mod vtext {
|
|||||||
/// Only supports the functional syntax
|
/// Only supports the functional syntax
|
||||||
mod vcomponent {
|
mod vcomponent {
|
||||||
use crate::innerlude::FC;
|
use crate::innerlude::FC;
|
||||||
use std::{any::TypeId, fmt, future::Future, marker::PhantomData};
|
use std::{marker::PhantomData};
|
||||||
|
|
||||||
use super::VNode;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct VComponent<'src> {
|
pub struct VComponent<'src> {
|
||||||
@@ -279,8 +279,8 @@ mod vcomponent {
|
|||||||
|
|
||||||
impl<'a> VComponent<'a> {
|
impl<'a> VComponent<'a> {
|
||||||
pub fn new<P>(caller: FC<P>, props: P) -> Self {
|
pub fn new<P>(caller: FC<P>, props: P) -> Self {
|
||||||
let caller = caller as *const ();
|
let _caller = caller as *const ();
|
||||||
let props = Box::new(props);
|
let _props = Box::new(props);
|
||||||
|
|
||||||
todo!()
|
todo!()
|
||||||
// Self {
|
// Self {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use crate::innerlude::*;
|
|||||||
use crate::nodes::VNode;
|
use crate::nodes::VNode;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use generational_arena::Index;
|
use generational_arena::Index;
|
||||||
use owning_ref::StableAddress;
|
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
borrow::{Borrow, BorrowMut},
|
borrow::{Borrow, BorrowMut},
|
||||||
@@ -105,7 +105,7 @@ impl Scope {
|
|||||||
/// Update this component's props with a new set of props, remotely
|
/// Update this component's props with a new set of props, remotely
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
pub(crate) fn update_props<'a, P>(&self, new_props: P) -> crate::error::Result<()> {
|
pub(crate) fn update_props<'a, P>(&self, _new_props: P) -> crate::error::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ impl Scope {
|
|||||||
// these lifetimes could be very broken, so we need to dynamically manage them
|
// these lifetimes could be very broken, so we need to dynamically manage them
|
||||||
let caller = std::mem::transmute::<*const (), FC<PLocked>>(self.caller);
|
let caller = std::mem::transmute::<*const (), FC<PLocked>>(self.caller);
|
||||||
let props = self.props.downcast_ref::<PLocked>().unwrap();
|
let props = self.props.downcast_ref::<PLocked>().unwrap();
|
||||||
let nodes: DomTree = caller(ctx, props);
|
let _nodes: DomTree = caller(ctx, props);
|
||||||
todo!("absorb domtree into self")
|
todo!("absorb domtree into self")
|
||||||
// let nodes: VNode<'bump> = caller(ctx, props);
|
// let nodes: VNode<'bump> = caller(ctx, props);
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
changelist::{self, EditList},
|
changelist::{self, EditList},
|
||||||
dodriodiff::DiffMachine,
|
dodriodiff::DiffMachine,
|
||||||
nodes::VNode,
|
|
||||||
};
|
};
|
||||||
use crate::{events::EventTrigger, innerlude::*};
|
use crate::{events::EventTrigger, innerlude::*};
|
||||||
use any::Any;
|
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use changelist::EditMachine;
|
|
||||||
use generational_arena::{Arena, Index};
|
use generational_arena::{Arena, Index};
|
||||||
use std::{
|
use std::{
|
||||||
any::{self, TypeId},
|
any::{self, TypeId},
|
||||||
@@ -107,7 +106,7 @@ impl VirtualDom {
|
|||||||
let EventTrigger {
|
let EventTrigger {
|
||||||
component_id,
|
component_id,
|
||||||
listener_id,
|
listener_id,
|
||||||
event,
|
event: _,
|
||||||
} = evt;
|
} = evt;
|
||||||
|
|
||||||
let component = self
|
let component = self
|
||||||
@@ -159,13 +158,13 @@ impl VirtualDom {
|
|||||||
fn process_lifecycle(&mut self, LifecycleEvent { event_type }: LifecycleEvent) -> Result<()> {
|
fn process_lifecycle(&mut self, LifecycleEvent { event_type }: LifecycleEvent) -> Result<()> {
|
||||||
match event_type {
|
match event_type {
|
||||||
// Component needs to be mounted to the virtual dom
|
// Component needs to be mounted to the virtual dom
|
||||||
LifecycleType::Mount { to, under, props } => {}
|
LifecycleType::Mount { to: _, under: _, props: _ } => {}
|
||||||
|
|
||||||
// The parent for this component generated new props and the component needs update
|
// The parent for this component generated new props and the component needs update
|
||||||
LifecycleType::PropsChanged { props, component } => {}
|
LifecycleType::PropsChanged { props: _, component: _ } => {}
|
||||||
|
|
||||||
// Component was messaged via the internal subscription service
|
// Component was messaged via the internal subscription service
|
||||||
LifecycleType::Callback { component } => {}
|
LifecycleType::Callback { component: _ } => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -216,7 +215,7 @@ pub enum LifecycleType {
|
|||||||
impl LifecycleEvent {
|
impl LifecycleEvent {
|
||||||
fn index(&self) -> Option<Index> {
|
fn index(&self) -> Option<Index> {
|
||||||
match &self.event_type {
|
match &self.event_type {
|
||||||
LifecycleType::Mount { to, under, props } => None,
|
LifecycleType::Mount { to: _, under: _, props: _ } => None,
|
||||||
|
|
||||||
LifecycleType::PropsChanged { component, .. }
|
LifecycleType::PropsChanged { component, .. }
|
||||||
| LifecycleType::Callback { component } => Some(component.clone()),
|
| LifecycleType::Callback { component } => Some(component.clone()),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
// use crate::prelude::*;
|
// use crate::prelude::*;
|
||||||
use dioxus_core::prelude::*;
|
|
||||||
// type VirtualNode = VNode;
|
// type VirtualNode = VNode;
|
||||||
|
|
||||||
/// Test a basic usage of a virtual dom + text renderer combo
|
/// Test a basic usage of a virtual dom + text renderer combo
|
||||||
|
|||||||
Reference in new issue
Block a user