add readable and writable traits for signal-like structs
This commit is contained in:
1 parent
93adb35cfa
commit
51d7133ca5
17 files changed
+756
-673
No files matched your search
@@ -0,0 +1,25 @@
|
||||
use dioxus_core::prelude::{provide_root_context, try_consume_context};
|
||||
use std::{any::Any, cell::RefCell, collections::HashMap, rc::Rc};
|
||||
|
||||
mod memo;
|
||||
pub use memo::*;
|
||||
|
||||
mod signal;
|
||||
pub use signal::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct GlobalSignalContext {
|
||||
signal: Rc<RefCell<HashMap<*const (), Box<dyn Any>>>>,
|
||||
}
|
||||
|
||||
pub(crate) fn get_global_context() -> GlobalSignalContext {
|
||||
match try_consume_context() {
|
||||
Some(context) => context,
|
||||
None => {
|
||||
let context = GlobalSignalContext {
|
||||
signal: Rc::new(RefCell::new(HashMap::new())),
|
||||
};
|
||||
provide_root_context(context).unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user