MCPcopy
hub / github.com/reflex-dev/reflex / _add_event_handler

Method _add_event_handler

reflex/state.py:725–738  ·  view source on GitHub ↗

Add an event handler dynamically to the state. Args: name: The name of the event handler. fn: The function to call when the event is triggered.

(
        cls,
        name: str,
        fn: Callable,
    )

Source from the content-addressed store, hash-verified

723
724 @classmethod
725 def _add_event_handler(
726 cls,
727 name: str,
728 fn: Callable,
729 ):
730 """Add an event handler dynamically to the state.
731
732 Args:
733 name: The name of the event handler.
734 fn: The function to call when the event is triggered.
735 """
736 handler = cls._create_event_handler(fn)
737 cls.event_handlers[name] = handler
738 setattr(cls, name, handler)
739
740 @staticmethod
741 def _copy_fn(fn: Callable) -> Callable:

Callers 2

wrapperMethod · 0.80
test_dynamic_var_eventFunction · 0.80

Calls 1

_create_event_handlerMethod · 0.80

Tested by 1

test_dynamic_var_eventFunction · 0.64