Hotreload the contents of for loops, if chains, component bodies, props, attributes, and any literals discovered in rsx! Add a TUI renderer to the CLI. Improve the CLI build system to be async and parallel. Refactor RSX to allow partial expansion of expressions. Merge autofmt implementations for consistency. Merge the representation of elements and components under the hood. Add a diagnostics system for rsx for improved error messages. Drop interprocess and move to websockets for communication between the CLI and the server. Assign IDs to nodes and attributes in a stable way to be used in non compiler contexts. Add hotreloading to any body of component/for loop/if chain/etc. --------- Co-authored-by: Evan Almloff <evanalmloff@gmail.com> Co-authored-by: Liam Mitchell <liamkarlmitchell@gmail.com>
44 lines
1.6 KiB
Rust
44 lines
1.6 KiB
Rust
use crate::HotReloadMsg;
|
|
use dioxus_core::{internal::HotReloadLiteral, ScopeId, VirtualDom};
|
|
use dioxus_signals::Writable;
|
|
|
|
/// Applies template and literal changes to the VirtualDom
|
|
///
|
|
/// Assets need to be handled by the renderer.
|
|
pub fn apply_changes(dom: &mut VirtualDom, msg: &HotReloadMsg) {
|
|
for templates in &msg.templates {
|
|
for template in &templates.templates {
|
|
dom.replace_template(*template);
|
|
}
|
|
|
|
dom.runtime().on_scope(ScopeId::ROOT, || {
|
|
let ctx = dioxus_signals::get_global_context();
|
|
|
|
for (id, literal) in templates.changed_lits.iter() {
|
|
match &literal {
|
|
HotReloadLiteral::Fmted(f) => {
|
|
if let Some(mut signal) = ctx.get_signal_with_key(id) {
|
|
signal.set(f.clone());
|
|
}
|
|
}
|
|
HotReloadLiteral::Float(f) => {
|
|
if let Some(mut signal) = ctx.get_signal_with_key::<f64>(id) {
|
|
signal.set(*f);
|
|
}
|
|
}
|
|
HotReloadLiteral::Int(f) => {
|
|
if let Some(mut signal) = ctx.get_signal_with_key::<i64>(id) {
|
|
signal.set(*f);
|
|
}
|
|
}
|
|
HotReloadLiteral::Bool(f) => {
|
|
if let Some(mut signal) = ctx.get_signal_with_key::<bool>(id) {
|
|
signal.set(*f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|