-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2473 from plotly/fix-2221
Add callback id to long callback key generation.
- Loading branch information
Showing
7 changed files
with
62 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from dash import Dash, Input, Output, html | ||
|
||
from tests.integration.long_callback.utils import get_long_callback_manager | ||
|
||
long_callback_manager = get_long_callback_manager() | ||
handle = long_callback_manager.handle | ||
|
||
app = Dash(__name__, long_callback_manager=long_callback_manager) | ||
|
||
app.layout = html.Div( | ||
[ | ||
html.Button("click 1", id="button-1"), | ||
html.Button("click 2", id="button-2"), | ||
html.Div(id="output-1"), | ||
html.Div(id="output-2"), | ||
] | ||
) | ||
|
||
|
||
def gen_callback(index): | ||
@app.callback( | ||
Output(f"output-{index}", "children"), | ||
Input(f"button-{index}", "n_clicks"), | ||
background=True, | ||
prevent_initial_call=True, | ||
) | ||
def callback_name(_): | ||
return f"Clicked on {index}" | ||
|
||
|
||
for i in range(1, 3): | ||
gen_callback(i) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run_server(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters