Get the current :class:`~reactpy.backend.types.Connection`.
()
| 9 | |
| 10 | |
| 11 | def use_connection() -> Connection[Any]: # nocov |
| 12 | """Get the current :class:`~reactpy.backend.types.Connection`.""" |
| 13 | warn( |
| 14 | "The module reactpy.backend.hooks has been deprecated and will be deleted in the future. " |
| 15 | "Call reactpy.use_connection instead.", |
| 16 | DeprecationWarning, |
| 17 | ) |
| 18 | |
| 19 | conn = use_context(ConnectionContext) |
| 20 | if conn is None: |
| 21 | msg = "No backend established a connection." |
| 22 | raise RuntimeError(msg) |
| 23 | return conn |
| 24 | |
| 25 | |
| 26 | def use_scope() -> MutableMapping[str, Any]: # nocov |
no test coverage detected