Kaynağa Gözat

Feat: provide root context as method on virtualdom (#2243)

Jonathan Kelley 1 yıl önce
ebeveyn
işleme
6f3c5518ca
1 değiştirilmiş dosya ile 5 ekleme ve 0 silme
  1. 5 0
      packages/core/src/virtual_dom.rs

+ 5 - 0
packages/core/src/virtual_dom.rs

@@ -361,6 +361,11 @@ impl VirtualDom {
         self
     }
 
+    /// Provide a context to the root scope
+    pub fn provide_root_context<T: Clone + 'static>(&self, context: T) {
+        self.base_scope().state().provide_context(context);
+    }
+
     /// Build the virtualdom with a global context inserted into the base scope
     ///
     /// This method is useful for when you want to provide a context in your app without knowing its type