Skip to content

Commit 608469c

Browse files
committed
throw error on multiple callbacks targeting same output
1 parent 0a9e25f commit 608469c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/app/callbacks.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ function _callback!(func::Union{Function, ClientsideFunction, String}, app::Dash
129129
check_callback(func, app, deps)
130130

131131
out_symbol = Symbol(output_string(deps))
132+
haskey(app.callbacks, out_symbol) && error("Multiple callbacks can not target the same output.")
132133
callback_func = make_callback_func!(app, func, deps)
133134
push!(
134135
app.callbacks,

test/callbacks.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,24 @@ end
306306

307307
end
308308

309+
@testset "multiple callbacks targeting same output" begin
310+
app = dash()
311+
312+
app.layout = html_div() do
313+
dcc_input(id = "my-id", value="initial value", type = "text"),
314+
dcc_input(id = "my-id2", value="initial value2", type = "text"),
315+
html_div(id = "my-div")
316+
end
317+
318+
callback!(app, Output("my-div","children"), Input("my-id","value")) do value
319+
return value
320+
end
321+
322+
@test_throws ErrorException callback!(app, Output("my-div","children"), Input("my-id2","value")) do value
323+
return "v_$(value)"
324+
end
325+
end
326+
309327
@testset "empty triggered params" begin
310328
app = dash()
311329
app.layout = html_div() do

0 commit comments

Comments
 (0)