Repository: plotly/dash
File: dash/_callback.py (Python)

Code before:
        :param interval:
            Time to wait between the background callback update requests.
        :param on_error:
            Function to call when the callback raises an exception. Receives the
            exception object as first argument. The callback_context can be used
            to access the original callback inputs, states and output.
        :param optional:
            Mark all dependencies as not required on the initial layout checks.
        :param hidden:
            Hide the callback from the devtools callbacks tab.
        :param api_endpoint:
            If provided, the callback will be available at the given API endpoint.
            This allows you to call the callback directly through HTTP requests
            instead of through the Dash front-end. The endpoint should be a string
            that starts with a forward slash (e.g. `/my_callback`).
            The endpoint is relative to the Dash app's base URL.
            Note that the endpoint will not appear in the list of registered
            callbacks in the Dash devtools.
    """

    background_spec: Any = None

    config_prevent_initial_callbacks = _kwargs.pop(
        "config_prevent_initial_callbacks", False
    )
    config_hide_all_callbacks = _kwargs.pop("config_hide_all_callbacks", False)
    callback_map = _kwargs.pop("callback_map", GLOBAL_CALLBACK_MAP)
    callback_list = _kwargs.pop("callback_list", GLOBAL_CALLBACK_LIST)

    if background:
        background_spec = {
            "interval": interval,
        }

        if manager:
            background_spec["manager"] = manager

        if progress:
            background_spec["progress"] = coerce_to_list(progress)
            validate_background_inputs(background_spec["progress"])

        if progress_default:
            background_spec["progressDefault"] = coerce_to_list(progress_default)

            if not len(background_spec["progress"]) == len(
                background_spec["progressDefault"]
            ):
                raise Exception(
                    "Progress and progress default needs to be of same length"
                )


Review comment (refactor):
How are those actually insert when using `@callback` directly? I think we need a better system for those since we want the same behavior for both `@app.callback` and `@callback`.

Think you can refactor these config into a context and use the context instead of passing them around?

Code after:
        :param interval:
            Time to wait between the background callback update requests.
        :param on_error:
            Function to call when the callback raises an exception. Receives the
            exception object as first argument. The callback_context can be used
            to access the original callback inputs, states and output.
        :param optional:
            Mark all dependencies as not required on the initial layout checks.
        :param hidden:
            Hide the callback from the devtools callbacks tab.
        :param api_endpoint:
            If provided, the callback will be available at the given API endpoint.
            This allows you to call the callback directly through HTTP requests
            instead of through the Dash front-end. The endpoint should be a string
            that starts with a forward slash (e.g. `/my_callback`).
            The endpoint is relative to the Dash app's base URL.
            Note that the endpoint will not appear in the list of registered
            callbacks in the Dash devtools.
    """

    background_spec: Any = None

    config_prevent_initial_callbacks = _kwargs.pop(
        "config_prevent_initial_callbacks", False
    )
    callback_map = _kwargs.pop("callback_map", GLOBAL_CALLBACK_MAP)
    callback_list = _kwargs.pop("callback_list", GLOBAL_CALLBACK_LIST)

    if background:
        background_spec = {
            "interval": interval,
        }

        if manager:
            background_spec["manager"] = manager

        if progress:
            background_spec["progress"] = coerce_to_list(progress)
            validate_background_inputs(background_spec["progress"])

        if progress_default:
            background_spec["progressDefault"] = coerce_to_list(progress_default)

            if not len(background_spec["progress"]) == len(
                background_spec["progressDefault"]
            ):
                raise Exception(
                    "Progress and progress default needs to be of same length"
                )

        if cancel: