@@ -73,7 +73,7 @@ def on(
7373 stop_propagation:
7474 Block the event from propagating further up the DOM.
7575 prevent_default:
76- Stops the default actional associate with the event from taking place.
76+ Stops the default action associate with the event from taking place.
7777
7878 Returns:
7979 A decorator which accepts an event handler function as its first argument.
@@ -133,12 +133,10 @@ class EventHandler:
133133 The event handler object acts like a coroutine when called.
134134
135135 Parameters:
136- event_name:
137- The camel case name of the event.
138- target_id:
139- A unique identifier for the event handler. This is generally used if
140- an element has more than on event handler for the same event type. If
141- no ID is provided one will be generated automatically.
136+ stop_propagation:
137+ Block the event from propagating further up the DOM.
138+ prevent_default:
139+ Stops the default action associate with the event from taking place.
142140 """
143141
144142 __slots__ = (
@@ -160,13 +158,12 @@ def __init__(
160158 self ._func_handlers : List [Callable [..., Any ]] = []
161159
162160 def add (self , function : Callable [..., Any ]) -> "EventHandler" :
163- """Add a callback to the event handler.
161+ """Add a callback function or coroutine to the event handler.
164162
165163 Parameters:
166164 function:
167- The event handler function. Its parameters may indicate event attributes
168- which should be sent back from the fronend unless otherwise specified by
169- the ``properties`` parameter.
165+ The event handler function accepting parameters sent by the client.
166+ Typically this is a single ``event`` parameter that is a dictionary.
170167 """
171168 if asyncio .iscoroutinefunction (function ):
172169 self ._coro_handlers .append (function )
@@ -175,7 +172,7 @@ def add(self, function: Callable[..., Any]) -> "EventHandler":
175172 return self
176173
177174 def remove (self , function : Callable [..., Any ]) -> None :
178- """Remove the function from the event handler.
175+ """Remove the given function or coroutine from this event handler.
179176
180177 Raises:
181178 ValueError: if not found
@@ -185,6 +182,11 @@ def remove(self, function: Callable[..., Any]) -> None:
185182 else :
186183 self ._func_handlers .remove (function )
187184
185+ def clear (self ) -> None :
186+ """Remove all functions and coroutines from this event handler"""
187+ self ._coro_handlers .clear ()
188+ self ._func_handlers .clear ()
189+
188190 async def __call__ (self , data : List [Any ]) -> Any :
189191 """Trigger all callbacks in the event handler."""
190192 if self ._coro_handlers :
0 commit comments