Cleanup runtime code

This commit is contained in:
Jonathan Kelley committed 2024-01-16 17:38:39 -08:00
1 parent 8b9bf57c03
commit 3008870818
6 files changed
+97 -118

No files matched your search

+6 -5
View File
@@ -36,11 +36,12 @@ impl AssetHandlerRegistry {
responder: RequestAsyncResponder,
) {
if let Some(handler) = self.handlers.borrow().get(name) {
// make sure the runtime is alive for the duration of the handler
// We should do this for all the things - not just asset handlers
RuntimeGuard::with(self.dom_rt.clone(), Some(handler.scope), || {
(handler.f)(request, responder)
});
// Push the runtime onto the stack
let _guard = RuntimeGuard::new(self.dom_rt.clone());
// And run the handler in the scope of the component that created it
self.dom_rt
.on_scope(handler.scope, || (handler.f)(request, responder));
}
}