Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Proposal: support partial functions as EventHandlerFunction #1333

Answered by Archmonger
masipcat asked this question in Problem
Discussion options

Currently it's not possible to use a partial function as EventHandlerFunction. I could use a lambda for synchronous event handlers, but it won’t work for async event handlers.

Pseudo code of what I'm doing:

@component
def ListSelector(items):
 async def handle_select_list(item_id):
 await do_something(item_id)
 
 return [
 html.div(
 {
 "key": item["id"],
 "class": "list-select-option",
 "onclick": partial(handle_select_list, item["id"]),
 }
 )
 for item in items
 ]

I'm aware that I could refactor this code in a way that I don't need to use a partial or a lambda, but anyways, I thought it'd be better if it is supported.

It just need a couple of lines to support partial functions: masipcat@837a18c

Thank you!

You must be logged in to vote

Issue #1334 created. Feel free to PR this feature.

Replies: 1 comment

Comment options

Issue #1334 created. Feel free to PR this feature.

You must be logged in to vote
0 replies
Answer selected by Archmonger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /