Hotreloading of for/if/body, formatted strings, literals, component props, nested rsx, light CLI rewrite, cli TUI (#2258)
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>
This commit is contained in:
181 files changed
+12755
-10806
No files matched your search
@@ -1,5 +1,5 @@
|
||||
use crate::read_impls;
|
||||
use crate::{read::Readable, Memo, ReadableRef};
|
||||
use crate::{read_impls, GlobalKey};
|
||||
use dioxus_core::prelude::ScopeId;
|
||||
use generational_box::UnsyncStorage;
|
||||
use std::ops::Deref;
|
||||
@@ -11,20 +11,31 @@ use super::get_global_context;
|
||||
/// A signal that can be accessed from anywhere in the application and created in a static
|
||||
pub struct GlobalMemo<T: 'static> {
|
||||
selector: fn() -> T,
|
||||
key: GlobalKey<'static>,
|
||||
}
|
||||
|
||||
impl<T: PartialEq + 'static> GlobalMemo<T> {
|
||||
#[track_caller]
|
||||
/// Create a new global signal
|
||||
pub const fn new(selector: fn() -> T) -> GlobalMemo<T>
|
||||
where
|
||||
T: PartialEq,
|
||||
{
|
||||
GlobalMemo { selector }
|
||||
let key = std::panic::Location::caller();
|
||||
GlobalMemo {
|
||||
selector,
|
||||
key: GlobalKey::new(key),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the key for this global
|
||||
pub fn key(&self) -> GlobalKey<'static> {
|
||||
self.key.clone()
|
||||
}
|
||||
|
||||
/// Get the signal that backs this global.
|
||||
pub fn memo(&self) -> Memo<T> {
|
||||
let key = self as *const _ as *const ();
|
||||
let key = self.key();
|
||||
|
||||
let context = get_global_context();
|
||||
|
||||
|
||||
Reference in new issue
Block a user