diff --git a/packages/core/src/virtual_dom.rs b/packages/core/src/virtual_dom.rs index b18735cbe..60e97b9da 100644 --- a/packages/core/src/virtual_dom.rs +++ b/packages/core/src/virtual_dom.rs @@ -376,8 +376,8 @@ pub struct Scope { // pub event_queue: EventQueue, pub caller: Weak, - // pub caller: Weak>, - pub hookidx: RefCell, + + pub hookidx: Cell, // ========================== // slightly unsafe stuff @@ -503,7 +503,7 @@ impl Scope { // .ok_or(Error::FatalInternal("Borrowing listener failed"))? // .drain(..); - *self.hookidx.borrow_mut() = 0; + self.hookidx.set(0); let caller = self .caller @@ -714,7 +714,7 @@ pub trait Scoped<'src>: Sized { ) -> Output { let scope = self.get_scope(); - let idx = *scope.hookidx.borrow(); + let idx = scope.hookidx.get(); // Grab out the hook list let mut hooks = scope.hooks.borrow_mut(); @@ -725,7 +725,7 @@ pub trait Scoped<'src>: Sized { hooks.push(Box::pin(new_state)); } - *scope.hookidx.borrow_mut() += 1; + scope.hookidx.set(idx + 1); let stable_ref = hooks .get_mut(idx) @@ -853,15 +853,15 @@ Any function prefixed with "use" should not be called conditionally. ) } - fn suspend( + fn suspend VNode<'src> + 'src>( &self, - f: &'src mut Pin + Send + 'static>>, - g: impl FnOnce(SuspendedContext, O) -> VNode<'src> + 'src, + fut: &'src mut Pin + 'static>>, + callback: Fut, ) -> VNode<'src> { - match f.now_or_never() { - Some(o) => { + match fut.now_or_never() { + Some(out) => { let suspended_cx = SuspendedContext {}; - let nodes = g(suspended_cx, o); + let nodes = callback(suspended_cx, out); return nodes; } None => {