Skip to content

Callback context #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 14, 2020
Merged

Callback context #46

merged 9 commits into from
Jul 14, 2020

Conversation

waralex
Copy link
Collaborator

@waralex waralex commented Jul 13, 2020

Added the callback_context() function. This function only works from callback processing functions and returns a CallbackContext object :

mutable struct CallbackContext
    response::HTTP.Response
    inputs::Dict{String, Any}
    states::Dict{String, Any}
    outputs_list::Vector{Any}
    inputs_list::Vector{Any}
    states_list::Vector{Any}
    triggered::Union{Nothing, Vector{TriggeredParam}}
end

In addition, I refactored the code structure - distributed independent parts of the code to different files, designed the routing-related functionality as a sub-module, and so on. Therefore, the number of changed files in PR turned out to be significant, but for the most part it is copying code from old files to new ones.

@waralex waralex requested a review from alexcjohnson July 13, 2020 12:32
@github-actions github-actions bot added enhancement New feature or request tests labels Jul 13, 2020
@waralex waralex linked an issue Jul 13, 2020 that may be closed by this pull request
@@ -28,7 +28,7 @@ jobs:
- run:
name: 🔎 Unit tests
command: |
julia -e 'using Pkg; Pkg.update(); Pkg.add(PackageSpec(url="https://github.com/plotly/Dash.jl.git", rev=ENV["CIRCLE_BRANCH"])); Pkg.add(PackageSpec(url="https://github.com/waralex/dash-html-components.git", rev="jl_generator_test")); Pkg.add(PackageSpec(url="https://github.com/waralex/dash-core-components.git", rev="jl_generator_test")); Pkg.build("Dash"); Pkg.build("DashHtmlComponents"); Pkg.build("DashCoreComponents"); Pkg.test("Dash", coverage=true); function precompile_pkgs(); for pkg in collect(keys(Pkg.installed())); if !isdefined(Symbol(pkg), :Symbol) && pkg != "Compat.jl"; @info("Importing $(pkg)..."); try (@eval import $(Symbol(pkg))) catch end; end; end; end; precompile_pkgs()'
julia test/ci_prepare.jl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎 🍹 Much nicer, thanks!

outputs_list::Vector{Any}
inputs_list::Vector{Any}
states_list::Vector{Any}
triggered::Union{Nothing, Vector{TriggeredParam}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the Nothing necessary? Won't triggered at least be a length-0 Vector? Just trying to make sure this is as easy to use as possible, so users don't need fallback code for the Nothing case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcjohnson I agree, I'll fix it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/handlers.jl Outdated
include("handler/router.jl")
include("handler/base.jl")
#include("handler/router.jl")
#include("handler/base.jl")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obsolete?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic - just two minor comments, but the code & tests all look great. 💃

@waralex waralex merged commit 9acf95f into dev Jul 14, 2020
@etpinard etpinard deleted the callback_context branch June 13, 2023 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Callback context
2 participants