File tree 7 files changed +85
-84
lines changed
Filter options
7 files changed +85
-84
lines changed
Original file line number Diff line number Diff line change @@ -23,7 +23,9 @@ more info, see the :ref:`Contributor Guide <Creating a Changelog Entry>`.
23
23
Unreleased
24
24
----------
25
25
26
- Nothing yet...
26
+ Changed:
27
+
28
+ - :pull: `730 ` - Layout context management is not async
27
29
28
30
29
31
0.38.0-a2
@@ -444,7 +446,7 @@ See :ref:`Custom JavaScript Components` for details on the new interface.
444
446
- Make docs section margins larger - :issue: `450 `
445
447
- Search broken in docs - :issue: `443 `
446
448
- Move src/idom/client out of Python package - :issue: `429 `
447
- - Use composition instead of classes with Layout and LifeCycleHook - :issue: `412 `
449
+ - Use composition instead of classes async with Layout and LifeCycleHook - :issue: `412 `
448
450
- Remove Python language extension - :issue: `282 `
449
451
- Add keys to models so React doesn't complain of child arrays requiring them -
450
452
:issue: `255 `
Original file line number Diff line number Diff line change @@ -92,15 +92,15 @@ might look like:
92
92
93
93
**Added**
94
94
95
- - A really cool new feature - :pull:`123`
95
+ - :pull:`123` - A really cool new feature
96
96
97
97
**Changed**
98
98
99
- - The behavior of some existing feature - :pull:`456`
99
+ - :pull:`456` - The behavior of some existing feature
100
100
101
101
**Fixed**
102
102
103
- - Some really bad bug - :issue:`789`
103
+ - :issue:`789` - Some really bad bug
104
104
105
105
.. note ::
106
106
Original file line number Diff line number Diff line change @@ -61,9 +61,6 @@ class LayoutEvent(NamedTuple):
61
61
"""A list of event data passed to the event handler."""
62
62
63
63
64
- _Self = TypeVar ("_Self" , bound = "Layout" )
65
-
66
-
67
64
class Layout :
68
65
"""Responsible for "rendering" components. That is, turning them into VDOM."""
69
66
@@ -84,7 +81,7 @@ def __init__(self, root: "ComponentType") -> None:
84
81
raise TypeError (f"Expected a ComponentType, not { type (root )!r} ." )
85
82
self .root = root
86
83
87
- def __enter__ (self : _Self ) -> _Self :
84
+ async def __aenter__ (self ) -> Layout :
88
85
# create attributes here to avoid access before entering context manager
89
86
self ._event_handlers : EventHandlerDict = {}
90
87
@@ -98,7 +95,7 @@ def __enter__(self: _Self) -> _Self:
98
95
99
96
return self
100
97
101
- def __exit__ (self , * exc : Any ) -> None :
98
+ async def __aexit__ (self , * exc : Any ) -> None :
102
99
root_csid = self ._root_life_cycle_state_id
103
100
root_model_state = self ._model_states_by_life_cycle_state_id [root_csid ]
104
101
self ._unmount_model_states ([root_model_state ])
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ async def serve_json_patch(
39
39
recv : RecvCoroutine ,
40
40
) -> None :
41
41
"""Run a dispatch loop for a single view instance"""
42
- with layout :
42
+ async with layout :
43
43
try :
44
44
async with create_task_group () as task_group :
45
45
task_group .start_soon (_single_outgoing_loop , layout , send )
Original file line number Diff line number Diff line change @@ -51,7 +51,6 @@ def should_render(self: _OwnType, new: _OwnType) -> bool:
51
51
"""Whether the new component instance should be rendered."""
52
52
53
53
54
- _Self = TypeVar ("_Self" )
55
54
_Render = TypeVar ("_Render" , covariant = True )
56
55
_Event = TypeVar ("_Event" , contravariant = True )
57
56
@@ -66,11 +65,14 @@ async def render(self) -> _Render:
66
65
async def deliver (self , event : _Event ) -> None :
67
66
"""Relay an event to its respective handler"""
68
67
69
- def __enter__ (self : _Self ) -> _Self :
68
+ async def __aenter__ (self ) -> LayoutType [ _Render , _Event ] :
70
69
"""Prepare the layout for its first render"""
71
70
72
- def __exit__ (
73
- self , exc_type : Type [Exception ], exc_value : Exception , traceback : TracebackType
71
+ async def __aexit__ (
72
+ self ,
73
+ exc_type : Type [Exception ],
74
+ exc_value : Exception ,
75
+ traceback : TracebackType ,
74
76
) -> Optional [bool ]:
75
77
"""Clean up the view after its final render"""
76
78
You can’t perform that action at this time.
0 commit comments