Skip to content

Support partial functions as EventHandlerFunction #1334

@Archmonger

Description

@Archmonger

Discussed in #1333

Originally posted by masipcat February 7, 2026
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions