File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/py/reactpy/reactpy/core Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -64,10 +64,13 @@ class LifeCycleHook:
64
64
# and save state or add effects
65
65
current_hook().use_state(lambda: ...)
66
66
67
- async def effect ():
68
- yield
67
+ async def start_effect ():
68
+ ...
69
69
70
- current_hook().add_effect(effect)
70
+ async def stop_effect():
71
+ ...
72
+
73
+ current_hook().add_effect(start_effect, stop_effect)
71
74
finally:
72
75
await hook.affect_component_did_render()
73
76
@@ -140,7 +143,12 @@ def add_effect(
140
143
start_effect : Callable [[], Awaitable [None ]],
141
144
clean_effect : Callable [[], Awaitable [None ]],
142
145
) -> None :
143
- """Add an effect to this hook"""
146
+ """Add an effect to this hook
147
+
148
+ Effects are started when the component is done renderig and cleaned up when the
149
+ component is removed from the layout. Any other actions (e.g. re-running the
150
+ effect if a dependency changes) are the responsibility of the effect itself.
151
+ """
144
152
self ._effect_startups .append (start_effect )
145
153
self ._effect_cleanups .append (clean_effect )
146
154
You can’t perform that action at this time.
0 commit comments