Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

repeated, unnecessary calls to callbacks in this example #41

Closed
chriddyp opened this issue Jan 13, 2018 · 0 comments
Closed

repeated, unnecessary calls to callbacks in this example #41

chriddyp opened this issue Jan 13, 2018 · 0 comments
Labels
Type: Bug Something isn't working as intended

Comments

@chriddyp
Copy link
Member

import dash
from dash.dependencies import Input, Output
import dash_html_components as html
import dash_core_components as dcc

app = dash.Dash()

app.layout = html.Div([
    html.Div(id='session-id', children='id'),
    dcc.Dropdown(id='dropdown-1'),
    dcc.Dropdown(id='dropdown-2'),
    dcc.Dropdown(id='dropdown-2')
])

options = [{'value': 'a', 'label': 'a'}]

@app.callback(
    Output(component_id = 'dropdown-1', component_property = 'options'),
    [Input(component_id = 'dropdown-2', component_property = 'value'),
     Input('session-id', 'children')])
def dropdown_1(value, session_id):
    print('dropdown-1')
    return options

@app.callback(
    Output(component_id = 'dropdown-2', component_property = 'options'),
    [Input(component_id = 'dropdown-1', component_property = 'value'),
     Input('session-id', 'children')])
def dropdown_2(value, session_id):
    print('dropdown-2')
    return options


if __name__ == '__main__':
    app.run_server(debug=True)

Each callback is called twice, I believe that they should only be called once:

127.0.0.1 - - [13/Jan/2018 00:24:26] "GET /_dash-dependencies HTTP/1.1" 200 -
dropdown-1
127.0.0.1 - - [13/Jan/2018 00:24:27] "POST /_dash-update-component HTTP/1.1" 200 -
dropdown-2
127.0.0.1 - - [13/Jan/2018 00:24:27] "POST /_dash-update-component HTTP/1.1" 200 -
dropdown-1
127.0.0.1 - - [13/Jan/2018 00:24:27] "POST /_dash-update-component HTTP/1.1" 200 -
dropdown-2
127.0.0.1 - - [13/Jan/2018 00:24:27] "POST /_dash-update-component HTTP/1.1" 200 -
@chriddyp chriddyp added the Type: Bug Something isn't working as intended label Jan 13, 2018
@chriddyp chriddyp mentioned this issue Feb 1, 2018
chriddyp added a commit that referenced this issue Feb 1, 2018
chriddyp added a commit that referenced this issue Feb 2, 2018
Akronix pushed a commit to Grasia/dash-renderer that referenced this issue Mar 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Bug Something isn't working as intended
Projects
None yet
Development

No branches or pull requests

1 participant