add the ability to map signals

This commit is contained in:
Evan Almloff committed 2023-10-11 12:43:22 -05:00
1 parent c65a49fd0f
commit 3578f03f4f
4 files changed
+127 -2

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
#![allow(unused, non_upper_case_globals, non_snake_case)]
use dioxus::prelude::*;
use dioxus_core::ElementId;
use dioxus_signals::*;
#[test]
fn create_signals_global() {
let mut dom = VirtualDom::new(|cx| {
render! {
for _ in 0..10 {
Child {}
}
}
});
fn Child(cx: Scope) -> Element {
let signal = create_without_cx();
let mapped = SignalMap::new(signal, |v| v.as_bytes());
render! {
"{signal:?}"
"{mapped:?}"
}
}
let _edits = dom.rebuild().santize();
fn create_without_cx() -> Signal<String> {
Signal::new("hello world".to_string())
}
}