JuliaGizmos / InteractBase.jl

Build interactive HTML5 widgets in Julia
Other
27 stars 23 forks source link

implement onchange to only trigger on change signal #113

Closed piever closed 6 years ago

piever commented 6 years ago

An attempt to address https://github.com/JuliaGizmos/Interact.jl/issues/262

I don't like the keyword solution so much because I think with the current design it doesn't scale. There are several "helper functions" that can be applied to the most diverse widgets (like tooltip! to add a tooltip for example) and rather than providing many keyword for each widget it's probably easy to provide the helper functions directly so that the user can play with those and combine them.

In this case onchange turns a widget into an equivalent one whose signal gets updated only on "change" (an HTML5 concept that corresponds to releasing the slider for the range, or losing focus for a textbox/spinbox).

For example here one could do:

@manipulate for i=slider(1:100) |> onchange,
                j=slider(1:10) |> onchange
    scatter(rand(i), markersize = j)
end
codecov-io commented 6 years ago

Codecov Report

Merging #113 into master will increase coverage by 0.06%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #113      +/-   ##
==========================================
+ Coverage   95.26%   95.33%   +0.06%     
==========================================
  Files           9       10       +1     
  Lines         401      407       +6     
==========================================
+ Hits          382      388       +6     
  Misses         19       19
Impacted Files Coverage Δ
src/utils.jl 100% <ø> (ø) :arrow_up:
src/input.jl 96.73% <100%> (+0.03%) :arrow_up:
src/modifiers.jl 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 61ee446...6e18285. Read the comment docs.

Datseris commented 6 years ago

I checked out the branch. On my first usage of Interact I get:

┌ Warning: Client says it has unknown scope knockout-component-3e743f77-2d45-4093-ba12-72d5f6450b04
└ @ WebIO C:\Users\datseris\.julia\packages\WebIO\myl19\src\connection.jl:8
┌ Warning: Client says it has unknown scope knockout-component-7d20618a-0d81-4f7b-95a8-894559f8c645
└ @ WebIO C:\Users\datseris\.julia\packages\WebIO\myl19\src\connection.jl:8

many times over (I am using IJulia, as I don't know of any other way to use Interact). I assume it is unrelated.


Yeeeeeeeeeeeeeeeeeeeeeeees This does Exactly what I wanted! Thank you! (Please also add this to the documentation page)