From 4530994892ad7a4fa455d2c1cada983da87344c3 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 4 Apr 2024 16:35:40 +0200 Subject: [PATCH] pass stuff to json output --- src/app/callbacks.jl | 4 +++- src/app/supporttypes.jl | 3 ++- src/handler/state.jl | 3 ++- test/callbacks.jl | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/callbacks.jl b/src/app/callbacks.jl index c05f8c2..eb59bd7 100644 --- a/src/app/callbacks.jl +++ b/src/app/callbacks.jl @@ -127,6 +127,7 @@ end function _callback!(func::Union{Function, ClientsideFunction, String}, app::DashApp, deps::CallbackDeps; prevent_initial_call = nothing, background = false, + interval = 1000, manager = nothing) check_callback(func, app, deps) @@ -142,7 +143,8 @@ function _callback!(func::Union{Function, ClientsideFunction, String}, app::Dash isnothing(prevent_initial_call) ? get_setting(app, :prevent_initial_callbacks) : prevent_initial_call, - background + background, + interval ) ) end diff --git a/src/app/supporttypes.jl b/src/app/supporttypes.jl index 1d05847..396a8db 100644 --- a/src/app/supporttypes.jl +++ b/src/app/supporttypes.jl @@ -112,7 +112,8 @@ struct Callback func ::Union{Function, ClientsideFunction} dependencies ::CallbackDeps prevent_initial_call ::Bool - background ::Bool + long ::Bool + interval ::Int end is_multi_out(cb::Callback) = cb.dependencies.multi_out == true diff --git a/src/handler/state.jl b/src/handler/state.jl index 56232ce..68ff7d8 100644 --- a/src/handler/state.jl +++ b/src/handler/state.jl @@ -30,7 +30,8 @@ function _dependencies_json(app::DashApp) state = dependency_tuple.(callback.dependencies.state), output = output_string(callback.dependencies), clientside_function = _dep_clientside_func(callback.func), - prevent_initial_call = callback.prevent_initial_call + prevent_initial_call = callback.prevent_initial_call, + long = callback.long && (interval = callback.interval) ) end return JSON3.write(result) diff --git a/test/callbacks.jl b/test/callbacks.jl index 3c9dc4a..e71f3a5 100644 --- a/test/callbacks.jl +++ b/test/callbacks.jl @@ -674,4 +674,5 @@ end request = HTTP.Request("GET", "/_dash-dependencies") resp = Dash.HttpHelpers.handle(handler, request) deps = JSON3.read(String(resp.body)) + @test deps[1].long end \ No newline at end of file