Skip to content

Separate callbacks for on_process_result #429

@Makcal

Description

@Makcal

I have a dialog that can start several different dialogs, but is limited to have one on_process_result() callback. This is why to distinguish these calls I pass start_data in form of {"intent": "enter_name", "input": ...} and my callback looks like:

match start_data["intent"]:
    case "enter_name":
        # process input of the name field
        ...
    case "enter_text":
        # process input of the text field
        ...

This can produce long and complex callbacks. I wonder if there can be a cleaner way to process results. Thinking a while I've come up with two proposals:

  1. Pass a callback directly in a dialog's call:
await manager.start(PromptSG.main, promt_params, callback=process_name)`
  1. Use a decorator to mark a function as a callback for a particular dialog:
@dialog.callback_for(PromptDialog)
def process_name(start_data, result, manager)
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions