Repository: Avaiga/taipy
File: taipy/gui/gui_actions.py (Python)

Code before:
        args (Optional[Sequence]): The remaining arguments, as a List or a Tuple.
        module_context (Optional[str]): the name of the module that will be used.
    """
    if isinstance(gui, Gui):
        return gui.invoke_callback(state_id, callback, args, module_context)
    _warn("'invoke_callback()' must be called with a valid Gui instance.")


def broadcast_callback(
    gui: Gui,
    callback: t.Callable,
    args: t.Optional[t.Sequence[t.Any]] = None,
    module_context: t.Optional[str] = None,
) -> t.Dict[str, t.Any]:
    """Invoke a callback for every client.

    Calling this function is equivalent to calling the method
    *gui*.`(Gui.)broadcast_callback(callback, args)^`.

    Arguments:
        gui (Gui^): The current Gui instance.
        callback: The user-defined function to be invoked.<br/>
            The first parameter of this function must be a `State^` object representing the
            client for which it is invoked.<br/>
            The other arguments should reflect the ones provided in the *args* collection.
        args: The arguments to send to *callback*, if any.
    """
    if isinstance(gui, Gui):
        return gui.broadcast_callback(callback, args, module_context)
    _warn("'broadcast_callback()' must be called with a valid Gui instance.")


def invoke_state_callback(gui: Gui, state_id: str, callback: t.Callable, args: t.Union[t.Tuple, t.List]) -> t.Any:
    """NOT DOCUMENTED"""
    _warn("'invoke_state_callback()' was deprecated in Taipy GUI 2.0. Use 'Gui.invoke_callback()' instead.")
    return gui.invoke_callback(state_id, callback, args)


def invoke_long_callback(
    state: State,
    user_function: t.Callable,
    user_function_args: t.Optional[t.Union[t.Tuple, t.List]] = None,
    user_status_function: t.Optional[t.Callable] = None,
    user_status_function_args: t.Optional[t.Union[t.Tuple, t.List]] = None,
    period=0,
):
    """Invoke a long-running user callback.

    Long-running callbacks are run in a separate thread to not block the application itself.

    This function expects to be provided a function to run in the background (in *user_function*).<br/>

Review comment (suggestion):
```suggestion
            The other parameters should reflect the ones provided in the *args* collection.
        args: The parameters to send to *callback*, if any.
```

Code after:
        args (Optional[Sequence]): The remaining arguments, as a List or a Tuple.
        module_context (Optional[str]): the name of the module that will be used.
    """
    if isinstance(gui, Gui):
        return gui.invoke_callback(state_id, callback, args, module_context)
    _warn("'invoke_callback()' must be called with a valid Gui instance.")


def broadcast_callback(
    gui: Gui,
    callback: t.Callable,
    args: t.Optional[t.Sequence[t.Any]] = None,
    module_context: t.Optional[str] = None,
) -> t.Dict[str, t.Any]:
    """Invoke a callback for every client.

    Calling this function is equivalent to calling the method
    *gui*.`(Gui.)broadcast_callback(callback, args)^`.

    Arguments:
        gui (Gui^): The current Gui instance.
        callback: The user-defined function to be invoked.<br/>
            The first parameter of this function must be a `State^` object representing the
            client for which it is invoked.<br/>
            The other parameters should reflect the ones provided in the *args* collection.
        args: The parameters to send to *callback*, if any.
    """
    if isinstance(gui, Gui):
        return gui.broadcast_callback(callback, args, module_context)
    _warn("'broadcast_callback()' must be called with a valid Gui instance.")


def invoke_state_callback(gui: Gui, state_id: str, callback: t.Callable, args: t.Union[t.Tuple, t.List]) -> t.Any:
    """NOT DOCUMENTED"""
    _warn("'invoke_state_callback()' was deprecated in Taipy GUI 2.0. Use 'Gui.invoke_callback()' instead.")
    return gui.invoke_callback(state_id, callback, args)


def invoke_long_callback(
    state: State,
    user_function: t.Callable,
    user_function_args: t.Optional[t.Union[t.Tuple, t.List]] = None,
    user_status_function: t.Optional[t.Callable] = None,
    user_status_function_args: t.Optional[t.Union[t.Tuple, t.List]] = None,
    period=0,
):
    """Invoke a long-running user callback.

    Long-running callbacks are run in a separate thread to not block the application itself.

    This function expects to be provided a function to run in the background (in *user_function*).<br/>