2020
2121@component
2222def root_manager (child : Any ):
23+ """This component is serves as the parent component for any ReactPy component tree,
24+ which allows for the management of the entire component tree."""
2325 scope = hooks .use_connection ().scope
2426 _ , set_rerender = hooks .use_state (uuid4 )
2527
@@ -29,7 +31,7 @@ def setup_asgi_scope():
2931 any relevant actions."""
3032 scope ["reactpy" ]["rerender" ] = rerender
3133
32- async def rerender ():
34+ def rerender ():
3335 """Event that can force a rerender of the entire component tree."""
3436 set_rerender (uuid4 ())
3537
@@ -44,7 +46,7 @@ def auth_manager():
4446 Used to force persistent authentication between Django's websocket and HTTP stack."""
4547 from reactpy_django import config
4648
47- synchronize_requested , set_synchronize_requested = hooks .use_state (False )
49+ sync_needed , set_sync_needed = hooks .use_state (False )
4850 token = hooks .use_ref ("" )
4951 scope = hooks .use_connection ().scope
5052
@@ -54,19 +56,19 @@ def setup_asgi_scope():
5456 any relevant actions."""
5557 scope ["reactpy" ]["synchronize_auth" ] = synchronize_auth
5658
57- @hooks .use_effect (dependencies = [synchronize_requested ])
59+ @hooks .use_effect (dependencies = [sync_needed ])
5860 async def synchronize_auth_watchdog ():
59- """Detected if the client has taken too long to request a auth session synchronization.
61+ """Detect if the client has taken too long to request a auth session synchronization.
6062
6163 This effect will automatically be cancelled if the session is successfully
6264 synchronized (via effect dependencies)."""
63- if synchronize_requested :
65+ if sync_needed :
6466 await asyncio .sleep (config .REACTPY_AUTH_TOKEN_TIMEOUT + 0.1 )
6567 await asyncio .to_thread (
6668 _logger .warning ,
6769 f"Client did not switch authentication sessions within { config .REACTPY_AUTH_TOKEN_TIMEOUT } (REACTPY_AUTH_TOKEN_TIMEOUT) seconds." ,
6870 )
69- set_synchronize_requested (False )
71+ set_sync_needed (False )
7072
7173 async def synchronize_auth ():
7274 """Event that can command the client to switch HTTP auth sessions (to match the websocket session)."""
@@ -88,12 +90,12 @@ async def synchronize_auth():
8890 # Begin the process of synchronizing HTTP and websocket auth sessions
8991 obj = await AuthToken .objects .acreate (value = token .current , session_key = session .session_key )
9092 await obj .asave ()
91- set_synchronize_requested (True )
93+ set_sync_needed (True )
9294
9395 async def synchronize_auth_callback (status_code : int , response : str ):
9496 """This callback acts as a communication bridge, allowing the client to notify the server
9597 of the status of auth session switch."""
96- set_synchronize_requested (False )
98+ set_sync_needed (False )
9799 if status_code >= 300 or status_code < 200 :
98100 await asyncio .to_thread (
99101 _logger .error ,
@@ -103,7 +105,7 @@ async def synchronize_auth_callback(status_code: int, response: str):
103105 # If needed, synchronize authenication sessions by configuring all relevant session cookies.
104106 # This is achieved by commanding the client to perform a HTTP request to our session manager endpoint,
105107 # which will set any required cookies.
106- if synchronize_requested :
108+ if sync_needed :
107109 return HttpRequest (
108110 {
109111 "method" : "GET" ,
0 commit comments