Closed PhillippOhlandt closed 2 years ago
This is correct. The values are not propagated to the cells until the cells are reevaluated. I think you can change this by using Kino.Control.stream(...)
passing the checkbox and the interval, and calling Kino.VegaLite push API to update the chart: https://hexdocs.pm/kino/Kino.Control.html#stream/1
Ah that worked, thanks.
Here the updated code:
frame = Kino.Frame.new()
checkbox = Kino.Input.checkbox("My Checkbox")
interval = Kino.Control.interval(1000)
value = Kino.Input.read(checkbox)
Kino.Control.stream([checkbox , interval], value, fn event, v ->
case event do
%{type: :interval} ->
if (v) do
# do some action
end
v
%{type: :change, value: value} -> value
end
end)
I wanted to use a checkbox to control what is happening inside a
Kino.VegaLite.periodically
butKino.Input.read
always returns the value that was set when the iteration started.These are the Livebook code cells:
If run as is, the initial checkbox value will be
false
which will be printed to the output. Toggling the checkbox does not reflect in the new output.