force rerender after rsx is updated

This commit is contained in:
Evan Almloff committed 2022-06-04 15:31:40 -05:00
1 parent 031640c9a4
commit 586e29d815
2 files changed
+17 -2

No files matched your search

+1
View File
@@ -96,6 +96,7 @@ impl DesktopController {
RSX_CONTEXT.set_error_handler(DesktopErrorHandler {
latest_connection: latest_out_connection_handle,
});
RSX_CONTEXT.provide_scheduler_channel(dom.get_scheduler_channel());
// connect to processes for incoming data
std::thread::spawn(move || {
+16 -2
View File
@@ -1,5 +1,8 @@
use captuered_context::CapturedContext;
use dioxus_core::{Component, Element, LazyNodes, NodeFactory, Scope, ScopeState, VNode};
use dioxus_core::{
Component, Element, LazyNodes, NodeFactory, SchedulerMsg, Scope, ScopeId, ScopeState, VNode,
};
use dioxus_hooks::UnboundedSender;
use error::Error;
use interperter::build;
use lazy_static::lazy_static;
@@ -87,6 +90,7 @@ pub struct RsxContext {
pub struct RsxData {
pub hm: HashMap<CodeLocation, String>,
pub error_handler: Option<Box<dyn ErrorHandler>>,
pub scheduler_channel: Option<UnboundedSender<SchedulerMsg>>,
}
impl std::fmt::Debug for RsxData {
@@ -103,7 +107,13 @@ impl RsxContext {
}
pub fn insert(&self, loc: CodeLocation, text: String) {
self.data.write().unwrap().hm.insert(loc, text);
let mut write = self.data.write().unwrap();
write.hm.insert(loc, text);
if let Some(channel) = &mut write.scheduler_channel {
channel
.unbounded_send(SchedulerMsg::Immediate(ScopeId(0)))
.unwrap()
}
}
pub fn read(&self) -> RwLockReadGuard<RsxData> {
@@ -119,6 +129,10 @@ impl RsxContext {
pub fn set_error_handler(&self, handler: impl ErrorHandler + 'static) {
self.data.write().unwrap().error_handler = Some(Box::new(handler));
}
pub fn provide_scheduler_channel(&self, channel: UnboundedSender<SchedulerMsg>) {
self.data.write().unwrap().scheduler_channel = Some(channel)
}
}
pub trait ErrorHandler: Send + Sync {