1212)
1313
1414from anyio import create_task_group
15- from mypy_extensions import TypedDict
1615
1716
1817EventsMapping = Union [Dict [str , Union ["Callable[..., Any]" , "EventHandler" ]], "Events" ]
1918
2019
21- class EventTarget (TypedDict ):
22- target : str
23- preventDefault : bool # noqa
24- stopPropagation : bool # noqa
25-
26-
2720def event (
2821 function : Optional [Callable [..., Any ]] = None ,
2922 stop_propagation : bool = False ,
3023 prevent_default : bool = False ,
31- target_id : Optional [str ] = None ,
3224) -> Union ["EventHandler" , Callable [[Callable [..., Any ]], "EventHandler" ]]:
3325 """Create an event handler function with extra functionality.
3426
@@ -49,12 +41,8 @@ def event(
4941 Block the event from propagating further up the DOM.
5042 prevent_default:
5143 Stops the default actional associate with the event from taking place.
52- target_id:
53- A unique ID used to locate this handler in the resulting VDOM. This is
54- automatically generated by default and is typically not set manually
55- except in testing.
5644 """
57- handler = EventHandler (stop_propagation , prevent_default , target_id = target_id )
45+ handler = EventHandler (stop_propagation , prevent_default )
5846 if function is not None :
5947 handler .add (function )
6048 return handler
@@ -142,8 +130,6 @@ def __repr__(self) -> str: # pragma: no cover
142130class EventHandler :
143131 """An object which defines an event handler.
144132
145- Get a serialized reference to the handler via :meth:`Handler.serialize`.
146-
147133 The event handler object acts like a coroutine when called.
148134
149135 Parameters:
@@ -159,19 +145,16 @@ class EventHandler:
159145 "__weakref__" ,
160146 "_coro_handlers" ,
161147 "_func_handlers" ,
162- "target_id" ,
163148 "prevent_default" ,
164- "stop_propogation " ,
149+ "stop_propagation " ,
165150 )
166151
167152 def __init__ (
168153 self ,
169154 stop_propagation : bool = False ,
170155 prevent_default : bool = False ,
171- target_id : Optional [str ] = None ,
172156 ) -> None :
173- self .target_id = target_id or str (id (self ))
174- self .stop_propogation = stop_propagation
157+ self .stop_propagation = stop_propagation
175158 self .prevent_default = prevent_default
176159 self ._coro_handlers : List [Callable [..., Coroutine [Any , Any , Any ]]] = []
177160 self ._func_handlers : List [Callable [..., Any ]] = []
@@ -216,6 +199,3 @@ def __contains__(self, function: Any) -> bool:
216199 return function in self ._coro_handlers
217200 else :
218201 return function in self ._func_handlers
219-
220- def __repr__ (self ) -> str : # pragma: no cover
221- return f"{ type (self ).__name__ } ({ self .serialize ()} )"
0 commit comments