Initialize the app. Raises: ValueError: If the event namespace is not provided in the config. Also, if there are multiple client subclasses of rx.BaseState(Subclasses of rx.BaseState should consist of the DefaultState and the clien
(self)
| 465 | return self._event_processor |
| 466 | |
| 467 | def __post_init__(self): |
| 468 | """Initialize the app. |
| 469 | |
| 470 | Raises: |
| 471 | ValueError: If the event namespace is not provided in the config. |
| 472 | Also, if there are multiple client subclasses of rx.BaseState(Subclasses of rx.BaseState should consist |
| 473 | of the DefaultState and the client app state). |
| 474 | """ |
| 475 | # Special case to allow test cases have multiple subclasses of rx.BaseState. |
| 476 | if not is_testing_env() and BaseState.__subclasses__() != [State]: |
| 477 | # Only rx.State is allowed as Base State subclass. |
| 478 | msg = "rx.BaseState cannot be subclassed directly. Use rx.State instead" |
| 479 | raise ValueError(msg) |
| 480 | |
| 481 | get_config(reload=True) |
| 482 | |
| 483 | if "breakpoints" in self.style: |
| 484 | set_breakpoints(self.style.pop("breakpoints")) |
| 485 | |
| 486 | # Set up the API. |
| 487 | self._api = Starlette() |
| 488 | App._add_cors(self._api) |
| 489 | self._add_default_endpoints() |
| 490 | |
| 491 | for clz in App.__mro__: |
| 492 | if clz == App: |
| 493 | continue |
| 494 | if issubclass(clz, AppMixin): |
| 495 | clz._init_mixin(self) |
| 496 | |
| 497 | if self.enable_state: |
| 498 | self._enable_state() |
| 499 | |
| 500 | # Set up the admin dash. |
| 501 | self._setup_admin_dash() |
| 502 | |
| 503 | if sys.platform == "win32" and not is_prod_mode(): |
| 504 | # Hack to fix Windows hot reload issue. |
| 505 | from reflex.utils.compat import windows_hot_reload_lifespan_hack |
| 506 | |
| 507 | self.register_lifespan_task(windows_hot_reload_lifespan_hack) |
| 508 | |
| 509 | def _enable_state(self) -> None: |
| 510 | """Enable state for the app.""" |
nothing calls this directly
no test coverage detected