reactpy icon indicating copy to clipboard operation
reactpy copied to clipboard

Replace `reactpy.event` with dot notation callbacks

Open Archmonger opened this issue 2 years ago • 0 comments

Current Situation

Currently we utilize a decorator to allow for prevent_default and stop_propogation. But this syntax is pretty awkward.

@component
def LoginForm(props):

    @reactpy.event(prevent_default=True, stop_propogation=True)
    def handle_login(event):
        ...

Proposed Actions

Add callbacks to the event object which perform the same function, removing the need for a decorator.

@component
def LoginForm(props):

    def handle_login(event):
        event.prevent_default()
        event.stop_propogation()

It might also make sense to convert our event object from dict to object using Munch, as the dot interface feels a bit more JavaScripty.

Archmonger avatar Sep 21 '23 22:09 Archmonger