feat: split apart template mutations

This commit is contained in:
Jonathan Kelley committed 2022-11-08 19:39:37 -08:00
1 parent 203935834d
commit fc9fe6e560
21 files changed
+431 -222

No files matched your search

+14 -11
View File
@@ -6,7 +6,10 @@ use std::{
};
use super::{waker::RcWake, SchedulerMsg};
use crate::{innerlude::Mutation, Element, ScopeId};
use crate::{
innerlude::{Mutation, Renderer},
Element, ScopeId,
};
use futures_task::Waker;
use futures_util::Future;
@@ -14,27 +17,27 @@ use futures_util::Future;
pub struct SuspenseId(pub usize);
pub type SuspenseContext = Rc<RefCell<SuspenseBoundary>>;
/// Essentially a fiber in React
pub struct SuspenseBoundary {
pub id: ScopeId,
pub waiting_on: HashSet<SuspenseId>,
pub mutations: Vec<Mutation<'static>>,
pub mutations: Renderer<'static>,
}
impl SuspenseBoundary {
pub fn new(id: ScopeId) -> Self {
Self {
pub fn new(id: ScopeId) -> Rc<RefCell<Self>> {
Rc::new(RefCell::new(Self {
id,
waiting_on: Default::default(),
mutations: Default::default(),
}
mutations: Renderer::new(0),
}))
}
}
pub struct SuspenseLeaf {
pub id: SuspenseId,
pub scope_id: ScopeId,
pub boundary: ScopeId,
pub tx: futures_channel::mpsc::UnboundedSender<SchedulerMsg>,
pub notified: Cell<bool>,
@@ -43,10 +46,10 @@ pub struct SuspenseLeaf {
impl RcWake for SuspenseLeaf {
fn wake_by_ref(arc_self: &Rc<Self>) {
if arc_self.notified.get() {
return;
}
arc_self.notified.set(true);
// if arc_self.notified.get() {
// return;
// }
// arc_self.notified.set(true);
_ = arc_self
.tx
.unbounded_send(SchedulerMsg::SuspenseNotified(arc_self.id));