@@ -229,19 +229,6 @@ def context(
229
229
return context
230
230
231
231
232
- # backend implementations should establish this context at the root of an app
233
- ConnectionContext : Context [Connection [Any ] | None ] = create_context (None )
234
-
235
-
236
- def use_connection () -> Connection [Any ]:
237
- """Get the current :class:`~reactpy.backend.types.Connection`."""
238
- conn = use_context (ConnectionContext )
239
- if conn is None : # nocov
240
- msg = "No backend established a connection."
241
- raise RuntimeError (msg )
242
- return conn
243
-
244
-
245
232
def use_context (context : Context [_Type ]) -> _Type :
246
233
"""Get the current value for the given context type.
247
234
@@ -263,6 +250,19 @@ def use_context(context: Context[_Type]) -> _Type:
263
250
return provider .value
264
251
265
252
253
+ # backend implementations should establish this context at the root of an app
254
+ ConnectionContext : Context [Connection [Any ] | None ] = create_context (None )
255
+
256
+
257
+ def use_connection () -> Connection [Any ]:
258
+ """Get the current :class:`~reactpy.backend.types.Connection`."""
259
+ conn = use_context (ConnectionContext )
260
+ if conn is None : # nocov
261
+ msg = "No backend established a connection."
262
+ raise RuntimeError (msg )
263
+ return conn
264
+
265
+
266
266
def use_scope () -> MutableMapping [str , Any ]:
267
267
"""Get the current :class:`~reactpy.backend.types.Connection`'s scope."""
268
268
return use_connection ().scope
0 commit comments