MCPcopy Index your code
hub / github.com/reactive-python/reactpy / to_event_handler_function

Function to_event_handler_function

src/py/reactpy/reactpy/core/events.py:131–162  ·  view source on GitHub ↗

Make a :data:`~reactpy.core.proto.EventHandlerFunc` from a function or coroutine Parameters: function: A function or coroutine accepting a number of positional arguments. positional_args: Whether to pass the event parameters a positional args or as a list

(
    function: Callable[..., Any],
    positional_args: bool = True,
)

Source from the content-addressed store, hash-verified

129
130
131def to_event_handler_function(
132 function: Callable[..., Any],
133 positional_args: bool = True,
134) -> EventHandlerFunc:
135 """Make a :data:`~reactpy.core.proto.EventHandlerFunc` from a function or coroutine
136
137 Parameters:
138 function:
139 A function or coroutine accepting a number of positional arguments.
140 positional_args:
141 Whether to pass the event parameters a positional args or as a list.
142 """
143 if positional_args:
144 if asyncio.iscoroutinefunction(function):
145
146 async def wrapper(data: Sequence[Any]) -> None:
147 await function(*data)
148
149 else:
150
151 async def wrapper(data: Sequence[Any]) -> None:
152 function(*data)
153
154 return wrapper
155 elif not asyncio.iscoroutinefunction(function):
156
157 async def wrapper(data: Sequence[Any]) -> None:
158 function(data)
159
160 return wrapper
161 else:
162 return function
163
164
165def merge_event_handlers(

Callers 5

useMethod · 0.90
setupFunction · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by 1