# App callback without an output

**URL:** <https://community.plotly.com/t/app-callback-without-an-output/5502>\
**Category:** Dash Python\
**Created:** [August 23, 2017, 6:45am UTC](https://community.plotly.com/t/app-callback-without-an-output/5502 "2017-08-23T06:45:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![HansG](https://avatars.discourse-cdn.com/v4/letter/h/958977/32.png) [@HansG](https://community.plotly.com/u/HansG)\
**Post date:** [August 23, 2017, 6:45am UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/1 "2017-08-23T06:45:25Z")

</div>

Hi,

is it possible to define an app callback without an output?  
Best

---

<div class="post-metadata">

**Author:** ![alishobeiri](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@alishobeiri](https://community.plotly.com/u/alishobeiri)\
**Post date:** [August 23, 2017, 3:52pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/2 "2017-08-23T15:52:51Z")

</div>

From my experience, I haven’t been able to and I don’t think it is possible.

A common hack I use though is to create an `html.P(id='placeholder')` and use that to serve as the output on my callback.

---

<div class="post-metadata">

**Author:** ![HansG](https://avatars.discourse-cdn.com/v4/letter/h/958977/32.png) [@HansG](https://community.plotly.com/u/HansG)\
**Post date:** [August 23, 2017, 4:04pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/3 "2017-08-23T16:04:16Z")

</div>

Thats exactly what I did.  
I thought there is a better solution. But for now it works.

---

<div class="post-metadata">

**Author:** ![raghunath](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@raghunath](https://community.plotly.com/u/raghunath)\
**Post date:** [August 23, 2017, 4:48pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/4 "2017-08-23T16:48:06Z")

</div>

What purpose would a callback serve without an Output?.

If you want to use an output from a callback to use for other process/other inputs etc then you can use a hidden DIV like this

> html.Div(id=‘hidden-div’, style={‘display’:‘none’})

---

<div class="post-metadata">

**Author:** ![HansG](https://avatars.discourse-cdn.com/v4/letter/h/958977/32.png) [@HansG](https://community.plotly.com/u/HansG)\
**Post date:** [August 24, 2017, 7:01am UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/5 "2017-08-24T07:01:34Z")

</div>

Sometimes it is necessary if you just want to set new values in your “controller” but don’t want to trigger an action.  
But this can also be achieved with multiple input values.

---

<div class="post-metadata">

**Author:** ![DongyaoLi](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@DongyaoLi](https://community.plotly.com/u/DongyaoLi)\
**Post date:** [August 24, 2017, 4:56pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/6 "2017-08-24T16:56:04Z")

</div>

I have also been thinking about the same problem. Sometimes an action should first lead to certain calculation in the backend and I would naturally code it separately. But more often than not, this calculation can also be integrated into the next action which has an output. I would be interested to hear from a developer’s perspective on why Dash force a callback to have an output. Is there any consideration regarding performance or design?

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [August 24, 2017, 5:23pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/7 "2017-08-24T17:23:48Z")

</div>

> [@DongyaoLi](#):
>
> But more often than not, this calculation can also be integrated into the next action which has an output

In cases like these, you can “store” the output in a hidden DIV as JSON and then use that result in the next callbacks. See [Add reactive expressions / blocks · Issue #49 · plotly/dash · GitHub](https://github.com/plotly/dash/issues/49#issuecomment-311511286) for more details.

> [@DongyaoLi](#):
>
> I would be interested to hear from a developer’s perspective on why Dash force a callback to have an output. Is there any consideration regarding performance or design?

The main thing is that the Dash app backend’s state is read-only. The real “state” of the app is inside the front-end in the user’s web browser. Dash apps can’t modify global variables in the Python context because those modifications

- wouldn’t scale across multiple python processes (each with their own memory). when dash apps are deployed, they run on multiple processes.
- would need to be stored separately for each user, increasing the memory requirements of the backend considerably. instead, we store the state in the front-end in the user’s client.

If you want a callback to trigger a calculation, you have two options:

- store the results of the calculation in a hidden div as mentioned above
- perform the calculation and then set the output to be a hidden div and just return `None` or even raise an `Exception`
- perform the calculations one-time on app start
- perform the calcuations on page-load by setting `app.layout` to a function (as here: [Live Updates | Dash for Python Documentation | Plotly](https://plot.ly/dash/live-updates))

---

<div class="post-metadata">

**Author:** ![dolph54](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@dolph54](https://community.plotly.com/u/dolph54)\
**Post date:** [August 24, 2017, 7:48pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/8 "2017-08-24T19:48:15Z")

</div>

The missing option to allow users to modify the backend state is what keeps me from going with Dash instead of Jupyter Dahsboards right now. There are many use cases eg collaborative data exploration where having this at least be an option would be tremendously helpful.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [August 25, 2017, 3:45pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/9 "2017-08-25T15:45:00Z")

</div>

> [@dolph54](#):
>
> The missing option to allow users to modify the backend state

I’m curious to learn more about how this is limiting for certain types of examples. Could you post a simple example that demonstrates what you can’t accomplish without modifying the backend state?

---

<div class="post-metadata">

**Author:** ![dolph54](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@dolph54](https://community.plotly.com/u/dolph54)\
**Post date:** [August 25, 2017, 4:25pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/10 "2017-08-25T16:25:39Z")

</div>

For instance, if one user changes a view option in a chart or alters chart data, I’d like the option for that change to be propagated to all users. This would be really helpful for collaborative data exploration for a small team eg 2-5 users. If this can be done without modifying backend, I’d definitely be interested to know.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [August 25, 2017, 6:39pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/11 "2017-08-25T18:39:12Z")

</div>

> [@dolph54](#):
>
> if one user changes a view option in a chart or alters chart data, I’d like the option for that change to be propagated to all users

Ah, I see. Yes, Dash cannot do this right now - each user has _independent_ sessions when viewing dash apps.

---

<div class="post-metadata">

**Author:** ![dolph54](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@dolph54](https://community.plotly.com/u/dolph54)\
**Post date:** [August 26, 2017, 1:02pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/12 "2017-08-26T13:02:45Z")

</div>

I think it would be simple to add an option for users to mirror an existing session upon loading the page instead of creating a new one. The option could be implemented as a GET request so the user just needs to go to a slightly different URL (each session would be assigned a unique ID, and that ID could be stored in a variable that can be optionally added to the page in the Python code).

So, if user A loads a new session @ URL, they can copy and paste the ID from the dashboard and email it to their colleague, who joins @ URL/id=o3ino522

---

<div class="post-metadata">

**Author:** ![HansG](https://avatars.discourse-cdn.com/v4/letter/h/958977/32.png) [@HansG](https://community.plotly.com/u/HansG)\
**Post date:** [September 1, 2017, 1:30pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/13 "2017-09-01T13:30:04Z")

</div>

I updated my dash-core-components to the newest version. It seems like from version 0.10.0 upwards there is a new behaviour handling inputs and outputs.  
Until version 0.10.0 i was able to store intermediate results into a hidden div and use this div as an input to multiple other callbacks.  
Now this isn’t working any more. The result can still be stored into a hidden div but this does not trigger the next input

This was working before, but now it doesn’t (some-value-ui-state is a DIV):

```
@app.callback(
    Output('some-value-ui-state', 'children'),
    [Input('input-folder', 'value')])
def update_some_value_ui_state(folder):
    if folder:
        return some_function(folder)

@app.callback(
    Output('input-factors', 'options'),
    [Input('some-value-ui-state', 'children')])
def update_input_factor_options(value):
    return do_something_else()

```

 ![dash](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/a/aad7f1ee6362e01feff85e0f04708e0b97c1925e.PNG)

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [September 4, 2017, 6:46pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/15 "2017-09-04T18:46:55Z")

</div>

> [@dolph54](#):
>
> I think it would be simple to add an option for users to mirror an existing session upon loading the page instead of creating a new one

Saving and loading pre-saved sets of controls is definitely on the roadmap.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [September 4, 2017, 6:48pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/16 "2017-09-04T18:48:05Z")

</div>

> [@HansG](#):
>
> I updated my dash-core-components to the newest version. It seems like from version 0.10.0 upwards there is a new behaviour handling inputs and outputs.

@HansG - Could you create a new thread with this issue?

---

<div class="post-metadata">

**Author:** ![devxpy](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/devxpy/32/2866_2.png) [@devxpy](https://community.plotly.com/u/devxpy)\
**Post date:** [May 8, 2018, 3:59pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/17 "2018-05-08T15:59:47Z")

</div>

This feature would be great for people like me,

who design HAL interfaces for testing my IOT devices. Like buttons, dials etc…

---

<div class="post-metadata">

**Author:** ![radekwlsk](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/radekwlsk/32/1385_2.png) [@radekwlsk](https://community.plotly.com/u/radekwlsk)\
**Post date:** [May 14, 2018, 1:56pm UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/18 "2018-05-14T13:56:04Z")

</div>

Callbacks now handle `PreventUpdate()` exception rising by ignoring the callback output. So the callback can have output set to anything (like some dummy div or even `body` for kicks) and then just `raise PreventUpdate()` instead of returning a value.

---

<div class="post-metadata">

**Author:** ![Madhi](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@Madhi](https://community.plotly.com/u/Madhi)\
**Post date:** [October 3, 2018, 11:27am UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/19 "2018-10-03T11:27:53Z")

</div>

without getting any input can we display the output to the div?

---

<div class="post-metadata">

**Author:** ![coolertea](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@coolertea](https://community.plotly.com/u/coolertea)\
**Post date:** [June 22, 2019, 7:21am UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/20 "2019-06-22T07:21:38Z")

</div>

This would be useful if I just want to print and see what the Input looks like, helps learn how to use the Input. Problem is, only one callback allowed per output, so for every such variable I want to inspect I have to create a new output. Or, input all Inputs in the same callback and and check the context global in the callback…both doable, just tedious

---

<div class="post-metadata">

**Author:** ![sqzhang](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/sqzhang/32/6877_2.png) [@sqzhang](https://community.plotly.com/u/sqzhang)\
**Post date:** [June 24, 2019, 6:02am UTC](https://community.plotly.com/t/app-callback-without-an-output/5502/21 "2019-06-24T06:02:00Z")

</div>

you can prevent the output via raising a exception.

```auto
import dash

@app.callback(
    dash.dependencies.Output('button', 'style'),
    [
        dash.dependencies.Input('button', 'n_clicks'),
    ] 
)

def update(n_clicks):
    if n_clicks == 0:
        raise dash.exceptions.PreventUpdate("cancel the callback")
    else:
        return {}

```

[Next page](https://community.plotly.com/t/app-callback-without-an-output/5502.md?page=2)
