Fix the router and stub out a number of crates to get compiling

This commit is contained in:
Jonathan Kelley committed 2024-01-13 20:51:37 -08:00
1 parent 4c6e515da4
commit fae0b08e61
226 files changed
+1057 -1482

No files matched your search

+12 -12
View File
@@ -11,8 +11,8 @@ use dioxus::prelude::*;
use dioxus_signals::*;
#[component]
fn App(cx: Scope) -> Element {
let signal = use_signal(cx, || "hello world".to_string());
fn App() -> Element {
let signal = use_signal(|| "hello world".to_string());
spawn(async move {
// signal is Copy even though String is not copy
@@ -34,9 +34,9 @@ use dioxus::prelude::*;
use dioxus_signals::*;
#[component]
fn App(cx: Scope) -> Element {
fn App() -> Element {
// Because signal is never read in this component, this component will not rerun when the signal changes
let signal = use_signal(cx, || 0);
let signal = use_signal(|| 0);
render! {
button {
@@ -74,17 +74,17 @@ use dioxus::prelude::*;
use dioxus_signals::*;
#[component]
fn App(cx: Scope) -> Element {
fn App() -> Element {
// Because signal is never read in this component, this component will not rerun when the signal changes
use_context_provider(cx, || Signal::new(0));
use_context_provider(|| Signal::new(0));
render! {
Child {}
}
}
#[component]
fn Child(cx: Scope) -> Element {
fn Child() -> Element {
let signal: Signal<i32> = *use_context(cx).unwrap();
// This component does read from the signal, so when the signal changes it will rerun
render! {
@@ -104,9 +104,9 @@ use dioxus::prelude::*;
use dioxus_signals::*;
#[component]
fn App(cx: Scope) -> Element {
let signal = use_signal(cx, || 0);
let doubled = use_selector(cx, || signal * 2);
fn App() -> Element {
let signal = use_signal(|| 0);
let doubled = use_selector(|| signal * 2);
render! {
button {
@@ -120,7 +120,7 @@ fn App(cx: Scope) -> Element {
}
#[component]
fn Child(cx: Scope, signal: ReadOnlySignal<usize>) -> Element {
fn Child(signal: ReadOnlySignal<usize>) -> Element {
render! {
"{signal}"
}
+3 -3
View File
@@ -7,16 +7,16 @@ fn main() {
dioxus_desktop::launch(app);
}
fn app(cx: Scope) -> Element {
fn app() -> Element {
// Because signal is never read in this component, this component will not rerun when the signal changes
use_context_provider(cx, || Signal::new(0));
use_context_provider(|| Signal::new(0));
render! {
Child {}
}
}
fn Child(cx: Scope) -> Element {
fn Child() -> Element {
let signal: Signal<i32> = *use_context(cx).unwrap();
// This component does read from the signal, so when the signal changes it will rerun
render! {
+7 -8
View File
@@ -7,21 +7,20 @@ fn main() {
dioxus_desktop::launch(app);
}
fn app(cx: Scope) -> Element {
let signal = use_signal(cx, || 0);
fn app() -> Element {
let signal = use_signal(|| 0);
use_future!(cx, || async move {
use_future!(|| async move {
loop {
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
*signal.write() += 1;
}
});
let local_state = use_state(cx, || 0);
let computed =
use_selector_with_dependencies(cx, (local_state.get(),), move |(local_state,)| {
local_state * 2 + signal.value()
});
let local_state = use_state(|| 0);
let computed = use_selector_with_dependencies((local_state.get(),), move |(local_state,)| {
local_state * 2 + signal.value()
});
println!("Running app");
render! {
+4 -4
View File
@@ -6,9 +6,9 @@ fn main() {
}
#[component]
fn App(cx: Scope) -> Element {
let signal = use_signal(cx, || 0);
let doubled = use_selector(cx, move || signal * 2);
fn App() -> Element {
let signal = use_signal(|| 0);
let doubled = use_selector(move || signal * 2);
render! {
button {
@@ -22,7 +22,7 @@ fn App(cx: Scope) -> Element {
}
#[component]
fn Child(cx: Scope, signal: ReadOnlySignal<usize>) -> Element {
fn Child(signal: ReadOnlySignal<usize>) -> Element {
render! {
"{signal}"
}
@@ -14,12 +14,12 @@ struct ApplicationData {
many_signals: Signal<Vec<Signal<i32>>>,
}
fn use_app_data(cx: Scope) -> ApplicationData {
fn use_app_data() -> ApplicationData {
*use_context(cx).unwrap()
}
fn app(cx: Scope) -> Element {
use_context_provider(cx, ApplicationData::default);
fn app() -> Element {
use_context_provider(ApplicationData::default);
render! {
div { ReadsFirst {} }
@@ -28,7 +28,7 @@ fn app(cx: Scope) -> Element {
}
}
fn ReadsFirst(cx: Scope) -> Element {
fn ReadsFirst() -> Element {
println!("running first");
let data = use_app_data(cx);
@@ -55,7 +55,7 @@ fn ReadsFirst(cx: Scope) -> Element {
}
}
fn ReadsSecond(cx: Scope) -> Element {
fn ReadsSecond() -> Element {
println!("running second");
let data = use_app_data(cx);
@@ -82,7 +82,7 @@ fn ReadsSecond(cx: Scope) -> Element {
}
}
fn ReadsManySignals(cx: Scope) -> Element {
fn ReadsManySignals() -> Element {
println!("running many signals");
let data = use_app_data(cx);
+8 -8
View File
@@ -12,12 +12,12 @@ use crate::{get_effect_stack, signal::SignalData, CopyValue, Effect, ReadOnlySig
/// use dioxus::prelude::*;
/// use dioxus_signals::*;
///
/// fn App(cx: Scope) -> Element {
/// let mut count = use_signal(cx, || 0);
/// let double = use_selector(cx, move || count * 2);
/// fn App() -> Element {
/// let mut count = use_signal(|| 0);
/// let double = use_selector(move || count * 2);
/// count += 1;
/// assert_eq!(double.value(), count * 2);
///
///
/// render! { "{double}" }
/// }
/// ```
@@ -34,11 +34,11 @@ pub fn use_selector<R: PartialEq>(f: impl FnMut() -> R + 'static) -> ReadOnlySig
/// use dioxus::prelude::*;
/// use dioxus_signals::*;
///
/// fn App(cx: Scope) -> Element {
/// let mut local_state = use_state(cx, || 0);
/// let double = use_selector_with_dependencies(cx, (local_state.get(),), move |(local_state,)| local_state * 2);
/// fn App() -> Element {
/// let mut local_state = use_state(|| 0);
/// let double = use_selector_with_dependencies((local_state.get(),), move |(local_state,)| local_state * 2);
/// local_state.set(1);
///
///
/// render! { "{double}" }
/// }
/// ```
+8 -8
View File
@@ -21,8 +21,8 @@ use crate::{get_effect_stack, CopyValue, Effect, EffectStack};
/// use dioxus::prelude::*;
/// use dioxus_signals::*;
///
/// fn App(cx: Scope) -> Element {
/// let mut count = use_signal(cx, || 0);
/// fn App() -> Element {
/// let mut count = use_signal(|| 0);
///
/// // Because signals have automatic dependency tracking, if you never read them in a component, that component will not be re-rended when the signal is updated.
/// // The app component will never be rerendered in this example.
@@ -30,10 +30,10 @@ use crate::{get_effect_stack, CopyValue, Effect, EffectStack};
/// }
///
/// #[component]
/// fn Child(cx: Scope, state: Signal<u32>) -> Element {
/// fn Child(state: Signal<u32>) -> Element {
/// let state = *state;
///
/// use_future!(cx, |()| async move {
/// use_future!( |()| async move {
/// // Because the signal is a Copy type, we can use it in an async block without cloning it.
/// *state.write() += 1;
/// });
@@ -105,8 +105,8 @@ pub(crate) struct SignalData<T> {
/// use dioxus_signals::*;
///
/// #[component]
/// fn App(cx: Scope) -> Element {
/// let mut count = use_signal(cx, || 0);
/// fn App() -> Element {
/// let mut count = use_signal(|| 0);
///
/// // Because signals have automatic dependency tracking, if you never read them in a component, that component will not be re-rended when the signal is updated.
/// // The app component will never be rerendered in this example.
@@ -114,10 +114,10 @@ pub(crate) struct SignalData<T> {
/// }
///
/// #[component]
/// fn Child(cx: Scope, state: Signal<u32>) -> Element {
/// fn Child(state: Signal<u32>) -> Element {
/// let state = *state;
///
/// use_future!(cx, |()| async move {
/// use_future!( |()| async move {
/// // Because the signal is a Copy type, we can use it in an async block without cloning it.
/// *state.write() += 1;
/// });
+3 -3
View File
@@ -14,7 +14,7 @@ fn create_signals_global() {
}
});
fn Child(cx: Scope) -> Element {
fn Child() -> Element {
let signal = create_without_cx();
render! {
@@ -39,7 +39,7 @@ fn deref_signal() {
}
});
fn Child(cx: Scope) -> Element {
fn Child() -> Element {
let signal = Signal::new("hello world".to_string());
// You can call signals like functions to get a Ref of their value.
@@ -66,7 +66,7 @@ fn drop_signals() {
}
});
fn Child(cx: Scope) -> Element {
fn Child() -> Element {
let signal = create_without_cx();
render! {
+1 -1
View File
@@ -22,7 +22,7 @@ fn effects_rerun() {
let counter = cx.props;
counter.borrow_mut().component += 1;
let mut signal = use_signal(cx, || 0);
let mut signal = use_signal(|| 0);
cx.use_hook(move || {
to_owned![counter];
Effect::new(move || {
+2 -2
View File
@@ -23,7 +23,7 @@ fn memos_rerun() {
let counter = cx.props;
counter.borrow_mut().component += 1;
let mut signal = use_signal(cx, || 0);
let mut signal = use_signal(|| 0);
let memo = cx.use_hook(move || {
to_owned![counter];
selector(move || {
@@ -63,7 +63,7 @@ fn memos_prevents_component_rerun() {
let counter = Rc::new(RefCell::new(RunCounter::default()));
let mut dom = VirtualDom::new_with_props(
|cx| {
let mut signal = use_signal(cx, || 0);
let mut signal = use_signal(|| 0);
if generation() == 1 {
*signal.write() = 0;
+1 -1
View File
@@ -19,7 +19,7 @@ fn reading_subscribes() {
let counter = Rc::new(RefCell::new(RunCounter::default()));
let mut dom = VirtualDom::new_with_props(
|cx| {
let mut signal = use_signal(cx, || 0);
let mut signal = use_signal(|| 0);
println!("Parent: {:?}", cx.scope_id());
if generation() == 1 {