Pārlūkot izejas kodu

promote run_in_thread from experimental (#5016)

Thomas Brandého 1 mēnesi atpakaļ
vecāks
revīzija
42d5b9d3d9
4 mainītis faili ar 19 papildinājumiem un 6 dzēšanām
  1. 1 0
      reflex/__init__.py
  2. 1 0
      reflex/__init__.pyi
  3. 17 6
      reflex/experimental/__init__.py
  4. 0 0
      reflex/utils/misc.py

+ 1 - 0
reflex/__init__.py

@@ -344,6 +344,7 @@ _MAPPING: dict = {
     "istate.wrappers": ["get_state"],
     "istate.wrappers": ["get_state"],
     "style": ["Style", "toggle_color_mode"],
     "style": ["Style", "toggle_color_mode"],
     "utils.imports": ["ImportDict", "ImportVar"],
     "utils.imports": ["ImportDict", "ImportVar"],
+    "utils.misc": ["run_in_thread"],
     "utils.serializers": ["serializer"],
     "utils.serializers": ["serializer"],
     "vars": ["Var", "field", "Field"],
     "vars": ["Var", "field", "Field"],
 }
 }

+ 1 - 0
reflex/__init__.pyi

@@ -197,6 +197,7 @@ from .style import Style as Style
 from .style import toggle_color_mode as toggle_color_mode
 from .style import toggle_color_mode as toggle_color_mode
 from .utils.imports import ImportDict as ImportDict
 from .utils.imports import ImportDict as ImportDict
 from .utils.imports import ImportVar as ImportVar
 from .utils.imports import ImportVar as ImportVar
+from .utils.misc import run_in_thread as run_in_thread
 from .utils.serializers import serializer as serializer
 from .utils.serializers import serializer as serializer
 from .vars import Field as Field
 from .vars import Field as Field
 from .vars import Var as Var
 from .vars import Var as Var

+ 17 - 6
reflex/experimental/__init__.py

@@ -8,10 +8,10 @@ from reflex.components.radix.themes.components.progress import progress as progr
 from reflex.components.sonner.toast import toast as toast
 from reflex.components.sonner.toast import toast as toast
 
 
 from ..utils.console import warn
 from ..utils.console import warn
+from ..utils.misc import run_in_thread
 from . import hooks as hooks
 from . import hooks as hooks
 from .client_state import ClientStateVar as ClientStateVar
 from .client_state import ClientStateVar as ClientStateVar
 from .layout import layout as layout
 from .layout import layout as layout
-from .misc import run_in_thread as run_in_thread
 
 
 
 
 class ExperimentalNamespace(SimpleNamespace):
 class ExperimentalNamespace(SimpleNamespace):
@@ -46,23 +46,35 @@ class ExperimentalNamespace(SimpleNamespace):
 
 
     @property
     @property
     def progress(self):
     def progress(self):
-        """Temporary property returning the toast namespace.
+        """Temporary property returning the progress component.
 
 
-        Remove this property when toast is fully promoted.
+        Remove this property when progress is fully promoted.
 
 
         Returns:
         Returns:
-            The toast namespace.
+            The progress component.
         """
         """
         self.register_component_warning("progress")
         self.register_component_warning("progress")
         return progress
         return progress
 
 
+    @property
+    def run_in_thread(self):
+        """Temporary property returning the run_in_thread helper function.
+
+        Remove this property when run_in_thread is fully promoted.
+
+        Returns:
+            The run_in_thread helper function.
+        """
+        self.register_component_warning("run_in_thread")
+        return run_in_thread
+
     @staticmethod
     @staticmethod
     def register_component_warning(component_name: str):
     def register_component_warning(component_name: str):
         """Add component to emitted warnings and throw a warning if it
         """Add component to emitted warnings and throw a warning if it
         doesn't exist.
         doesn't exist.
 
 
         Args:
         Args:
-             component_name: name of the component.
+            component_name: name of the component.
         """
         """
         warn(
         warn(
             f"`rx._x.{component_name}` was promoted to `rx.{component_name}`.",
             f"`rx._x.{component_name}` was promoted to `rx.{component_name}`.",
@@ -75,6 +87,5 @@ _x = ExperimentalNamespace(
     hooks=hooks,
     hooks=hooks,
     layout=layout,
     layout=layout,
     PropsBase=PropsBase,
     PropsBase=PropsBase,
-    run_in_thread=run_in_thread,
     code_block=code_block,
     code_block=code_block,
 )
 )

+ 0 - 0
reflex/experimental/misc.py → reflex/utils/misc.py