move ScopeId methods to the runtime (#4723)

* move `ScopeId` methods to runtime methods

* cargo check unused

* wip...

* wip...

* fix consume context

* fix test

* guard hoisted

* fix doc comment
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2025-10-04 01:55:52 -07:00
1 parent c56bac04f4
commit c29cef4ea3
40 files changed
+466 -697

No files matched your search

+5 -5
View File
@@ -353,7 +353,7 @@ impl VirtualDom {
/// Run a closure inside a specific scope
pub fn in_scope<T>(&self, scope: ScopeId, f: impl FnOnce() -> T) -> T {
self.in_runtime(|| scope.in_runtime(f))
self.runtime.in_scope(scope, f)
}
/// Build the virtualdom with a global context inserted into the base scope
@@ -393,7 +393,7 @@ impl VirtualDom {
///
/// Whenever the Runtime "works", it will re-render this scope
pub fn mark_dirty(&mut self, id: ScopeId) {
let Some(scope) = self.runtime.get_state(id) else {
let Some(scope) = self.runtime.try_get_state(id) else {
return;
};
@@ -408,7 +408,7 @@ impl VirtualDom {
let Some(scope) = self.runtime.task_scope(task) else {
return;
};
let Some(scope) = self.runtime.get_state(scope) else {
let Some(scope) = self.runtime.try_get_state(scope) else {
return;
};
@@ -718,7 +718,7 @@ impl VirtualDom {
let scope_id: ScopeId = scope.id;
let run_scope = self
.runtime
.get_state(scope.id)
.try_get_state(scope.id)
.filter(|scope| scope.should_run_during_suspense())
.is_some();
if run_scope {
@@ -747,7 +747,7 @@ impl VirtualDom {
}
self.resolved_scopes
.sort_by_key(|&id| self.runtime.get_state(id).unwrap().height);
.sort_by_key(|&id| self.runtime.get_state(id).height);
std::mem::take(&mut self.resolved_scopes)
}