Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Conversation

chriddyp
Copy link
Member

@chriddyp chriddyp commented Sep 7, 2017

No description provided.

@chriddyp chriddyp changed the title Fix reactive fix tree traversal with branched lineages Sep 7, 2017
@chriddyp
Copy link
Member Author

chriddyp commented Sep 7, 2017

Test case is:

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

app = dash.Dash(__name__)
server = app.server
app.layout = html.Div([
    dcc.Input(id='grandparent', value='input 1'),
    dcc.Input(id='parent-a'),
    dcc.Input(id='parent-b'),
    html.Div(id='child-a'),
    html.Div(id='child-b')
])

app.scripts.config.serve_locally = True


@app.callback(Output('parent-a', 'value'),
              [Input('grandparent', 'value')])
def update_parenta(value):
    print('parenta')
    time.sleep(2)
    return 'a: {}'.format(value)


@app.callback(Output('parent-b', 'value'),
              [Input('grandparent', 'value')])
def update_parentb(value):
    print('parentb')
    time.sleep(6)
    return 'b: {}'.format(value)


@app.callback(Output('child-a', 'children'),
              [Input('parent-a', 'value'),
               Input('parent-b', 'value')])
def update_childa(parenta_value, parentb_value):
    print('childa: {}, {}'.format(parenta_value, parentb_value))
    return '{} + {}'.format(parenta_value, parentb_value)


@app.callback(Output('child-b', 'children'),
              [Input('parent-a', 'value'),
               Input('parent-b', 'value'),
               Input('grandparent', 'value')])
def update_childb(parenta_value, parentb_value, grandparent_value):
    print('childb: {}, {}, {}'.format(
        parenta_value,
        parentb_value,
        grandparent_value
    ))
    return '{} + {} + {}'.format(
        parenta_value,
        parentb_value,
        grandparent_value
    )


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

@chriddyp chriddyp merged commit 04bd97a into master Sep 7, 2017
@chriddyp chriddyp deleted the fix-reactive branch September 7, 2017 20:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant