Normally used as a decorator, `@dash.callback` provides a server-side callback relating the values of one or more `Output` items to one or more `Input` items which will trigger the callback when they change, and optionally `State` items which provide additional information but d
(
*_args,
background: bool = False,
interval: int = 1000,
progress: Optional[Union[List[Output], Output]] = None,
progress_default: Any = None,
running: Optional[List[Tuple[Output, Any, Any]]] = None,
cancel: Optional[Union[List[Input], Input]] = None,
manager: Optional[BaseBackgroundCallbackManager] = None,
cache_args_to_ignore: Optional[list] = None,
cache_ignore_triggered=True,
on_error: Optional[Callable[[Exception], Any]] = None,
api_endpoint: Optional[str] = None,
optional: Optional[bool] = False,
hidden: Optional[bool] = None,
websocket: Optional[bool] = False,
persistent: Optional[bool] = False,
mcp_enabled: Optional[bool] = None,
mcp_expose_docstring: Optional[bool] = None,
**_kwargs,
)
| 70 | |
| 71 | # pylint: disable=too-many-locals,too-many-arguments |
| 72 | def callback( |
| 73 | *_args, |
| 74 | background: bool = False, |
| 75 | interval: int = 1000, |
| 76 | progress: Optional[Union[List[Output], Output]] = None, |
| 77 | progress_default: Any = None, |
| 78 | running: Optional[List[Tuple[Output, Any, Any]]] = None, |
| 79 | cancel: Optional[Union[List[Input], Input]] = None, |
| 80 | manager: Optional[BaseBackgroundCallbackManager] = None, |
| 81 | cache_args_to_ignore: Optional[list] = None, |
| 82 | cache_ignore_triggered=True, |
| 83 | on_error: Optional[Callable[[Exception], Any]] = None, |
| 84 | api_endpoint: Optional[str] = None, |
| 85 | optional: Optional[bool] = False, |
| 86 | hidden: Optional[bool] = None, |
| 87 | websocket: Optional[bool] = False, |
| 88 | persistent: Optional[bool] = False, |
| 89 | mcp_enabled: Optional[bool] = None, |
| 90 | mcp_expose_docstring: Optional[bool] = None, |
| 91 | **_kwargs, |
| 92 | ) -> Callable[[Callable[Params, ReturnVar]], Callable[Params, ReturnVar]]: |
| 93 | """ |
| 94 | Normally used as a decorator, `@dash.callback` provides a server-side |
| 95 | callback relating the values of one or more `Output` items to one or |
| 96 | more `Input` items which will trigger the callback when they change, |
| 97 | and optionally `State` items which provide additional information but |
| 98 | do not trigger the callback directly. |
| 99 | |
| 100 | `@dash.callback` is an alternative to `@app.callback` (where `app = dash.Dash()`) |
| 101 | introduced in Dash 2.0. |
| 102 | It allows you to register callbacks without defining or importing the `app` |
| 103 | object. The call signature is identical and it can be used instead of `app.callback` |
| 104 | in all cases. |
| 105 | |
| 106 | The last, optional argument `prevent_initial_call` causes the callback |
| 107 | not to fire when its outputs are first added to the page. Defaults to |
| 108 | `False` and unlike `app.callback` is not configurable at the app level. |
| 109 | |
| 110 | :Keyword Arguments: |
| 111 | :param background: |
| 112 | Mark the callback as a background callback to execute in a manager for |
| 113 | callbacks that take a long time without locking up the Dash app |
| 114 | or timing out. |
| 115 | :param manager: |
| 116 | A background callback manager instance. Currently, an instance of one of |
| 117 | `DiskcacheManager` or `CeleryManager`. |
| 118 | Defaults to the `background_callback_manager` instance provided to the |
| 119 | `dash.Dash constructor`. |
| 120 | - A diskcache manager (`DiskcacheManager`) that runs callback |
| 121 | logic in a separate process and stores the results to disk using the |
| 122 | diskcache library. This is the easiest backend to use for local |
| 123 | development. |
| 124 | - A Celery manager (`CeleryManager`) that runs callback logic |
| 125 | in a celery worker and returns results to the Dash app through a Celery |
| 126 | broker like RabbitMQ or Redis. |
| 127 | :param running: |
| 128 | A list of 3-element tuples. The first element of each tuple should be |
| 129 | an `Output` dependency object referencing a property of a component in |
searching dependent graphs…