#![allow(unused, non_upper_case_globals, non_snake_case)] use bumpalo::Bump; use dioxus_core::prelude::*; use dioxus_core::{nodebuilder::*, virtual_dom::Properties}; use std::{collections::HashMap, future::Future, marker::PhantomData}; fn main() { let mut vdom = VirtualDom::new_with_props( component, Props { blah: false, text: "blah", }, ); vdom.progress(); let somet = String::from("asd"); let text = somet.as_str(); /* this could be auto-generated via the macro this props is allocated in this but the component and props would like need to be cached we could box this fn, abstracting away the props requirement and just keep the entrance and allocator requirement How do we keep cached things around? Need some sort of caching mechanism how do we enter into a childscope from a parent scope? Problems: 1: Comp props need to be stored somewhere so we can re-evalute components when they receive updates 2: Trees are not evaluated */ let example_caller = move |ctx: &Bump| { todo!() // let p = Props { blah: true, text }; // let c = Context { props: &p }; // let r = component(&c); }; // check the edit list } // ~~~ Text shared between components via props can be done with lifetimes! ~~~ // Super duper efficient :) struct Props<'src> { blah: bool, text: &'src str, } impl<'src> Properties for Props<'src> { fn new() -> Self { todo!() } } fn component<'a>(ctx: Context<'a, Props>) -> VNode<'a> { // Write asynchronous rendering code that immediately returns a "suspended" VNode // The concurrent API will then progress this component when the future finishes // You can suspend the entire component, or just parts of it let product_list = ctx.suspend(async { // Suspend the rendering that completes when the future is done match fetch_data().await { Ok(data) => html! {
{ product_list }