Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVENT: Usability on handler's event argument #7

Open
pauleveritt opened this issue Oct 16, 2022 · 0 comments
Open

EVENT: Usability on handler's event argument #7

pauleveritt opened this issue Oct 16, 2022 · 0 comments

Comments

@pauleveritt
Copy link
Contributor

Some suggestions...

Optional?

The handler is currently defined with event=None. Looking at MDN, I don't believe None should be allowed. It appears the decorator has no real effect if event is None.

event -> trigger

Calling it event is going to make it seem like an instance of Event. HTMX uses htmx-trigger="click". Perhaps we could use trigger.

Positional vs. Keyword

I suggest the first argument (event type) is positional, everything else is keyword. The current zen of Python might be moving towards all-keyword.

Tooling-friendly contraint on event type

It sucks when you slightly misspell an event name. On the HTML/JS side, tools will warn you. Would be nice on the Python side.

We could do an Enum. I think Brett Cannon did a Twitter poll, not sure if people liked that.

We could instead do it on the type hinting side, with a union of Literal for each possible value. But perhaps we don't want this at all, for the (very rare) case of custom events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant