emilhe / dash-extensions

The dash-extensions package is a collection of utility functions, syntax extensions, and Dash components that aim to improve the Dash development experience
https://www.dash-extensions.com/
MIT License
417 stars 59 forks source link

Fix blocking callback bug #309

Closed lcornelatti closed 8 months ago

lcornelatti commented 8 months ago

Changes summary

Reason for changes

Testing

from dash_extensions.enrich import Dash, dcc, html, Input, Output, callback

app = Dash(__name__)

app.layout = html.Div([
    html.Div([
        "Input: ",
        dcc.Input(id='my-input', value='initial value', type='text')
    ]),
    html.P(id='my-output')
])

i = 0

@callback(
    Output('my-output', 'children'),
    Input('my-input', 'value'),
    prevent_initial_call=True,
    blocking=True,
)
def check_input(input_value):
    global i
    i += 1
    if input_value == "bad":
        raise Exception(f'input is bad! {i}')
    return i

if __name__ == '__main__':
    app.run(debug=False)
lcornelatti commented 8 months ago

Hey @emilhe , would appreciate a review here

emilhe commented 8 months ago

@lcornelatti Thanks for the PR! This is most definitly a bug. I have made a single suggestion for an improvement. Once that is cleared out, I believe the PR can be merged.

codecov[bot] commented 8 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (4392117) 80.45% compared to head (24a8ae3) 80.35%. Report is 2 commits behind head on master.

Files Patch % Lines
dash_extensions/enrich.py 77.77% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #309 +/- ## ========================================== - Coverage 80.45% 80.35% -0.10% ========================================== Files 10 10 Lines 1018 1023 +5 ========================================== + Hits 819 822 +3 - Misses 199 201 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.