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,
)
| 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: |