Unify the warning system (#2649)
* unify the warning system * fix VirtualDom::new warning with a component * move warnings to dioxuslabs * also allow writes in the component body when converting from T -> ReadOnlySignal<T> * fix clippy from merge conflict --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
f8cb07e673
commit
a6c025c8ef
10 files changed
+132
-63
No files matched your search
@@ -1,3 +1,4 @@
|
||||
use ::warnings::Warning;
|
||||
use dioxus_core::prelude::{consume_context, provide_context, spawn, use_hook};
|
||||
use dioxus_core::Task;
|
||||
use dioxus_signals::*;
|
||||
@@ -84,13 +85,17 @@ where
|
||||
|
||||
// We do this here so we can capture data with FnOnce
|
||||
// this might not be the best API
|
||||
if *coroutine.needs_regen.peek() {
|
||||
let (tx, rx) = futures_channel::mpsc::unbounded();
|
||||
let task = spawn(init(rx));
|
||||
coroutine.tx.set(Some(tx));
|
||||
coroutine.task.set(Some(task));
|
||||
coroutine.needs_regen.set(false);
|
||||
}
|
||||
dioxus_signals::warnings::signal_read_and_write_in_reactive_scope::allow(|| {
|
||||
dioxus_signals::warnings::signal_write_in_component_body::allow(|| {
|
||||
if *coroutine.needs_regen.peek() {
|
||||
let (tx, rx) = futures_channel::mpsc::unbounded();
|
||||
let task = spawn(init(rx));
|
||||
coroutine.tx.set(Some(tx));
|
||||
coroutine.task.set(Some(task));
|
||||
coroutine.needs_regen.set(false);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
coroutine
|
||||
}
|
||||
|
||||
@@ -110,7 +110,14 @@ pub fn use_reactive<O, D: Dependency>(
|
||||
non_reactive_data.out()
|
||||
});
|
||||
if !first_run && non_reactive_data.changed(&*last_state.peek()) {
|
||||
last_state.set(non_reactive_data.out());
|
||||
use warnings::Warning;
|
||||
// In use_reactive we do read and write to a signal during rendering to bridge the reactive and non-reactive worlds.
|
||||
// We ignore
|
||||
dioxus_signals::warnings::signal_read_and_write_in_reactive_scope::allow(|| {
|
||||
dioxus_signals::warnings::signal_write_in_component_body::allow(|| {
|
||||
last_state.set(non_reactive_data.out())
|
||||
})
|
||||
});
|
||||
}
|
||||
move || closure(last_state())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user