You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The value attribute of a DOM.input(; type="range") and the index attribute of a Slider are supposed to be of type Observable{Int}, but listeners receive an UInt8. I would expect they receive an Int instead.
This might be a bug in Observables.jl, but my experience with observables has been fairly stable so far. Type conversion systematically happens, or Julia complains.
My MRE is as follows:
using Observables
using Bonito
index1 = Observable{Int}(1)
oninput = js"(event) => { $index1.notify(parseInt(event.srcElement.value)) }"
slider1 = DOM.input(; type="range", min=1, max=10, value=index1, step=1, oninput=oninput)
on(index1) do i
@assert i isa Int "Expected Int, got $(typeof(i))"
end
# type conversation happens on a normal setindex!
index1[] = UInt8(1) # no error
@assert eltype(index1) === Int
slider2 = Slider(1:10)
index2 = slider2.index
@assert eltype(index2) === Int
on(index2) do i
@assert i isa Int "Expected Int, got $(typeof(i))"
end
App() do session
Bonito.jsrender(session, DOM.div(slider1, slider2))
end
This shows a webpage with two sliders. It also ensures the observables (index1 and index2)'s element type is Int and registers listeners that test whether the type of the input value is an Int as expected.
Clicking on any of the sliders makes the test fail and generates the exact same error message (appart from one line number):
Yeah this is due to our serialization protocol...
I tried once to recover original Julia types, but it was a bit hairy, so I decided this should be good enough.
If you really need an Int, one should just convert. We could also convert eagerly in user facing some places like slider
The
value
attribute of aDOM.input(; type="range")
and theindex
attribute of aSlider
are supposed to be of typeObservable{Int}
, but listeners receive anUInt8
. I would expect they receive anInt
instead.This might be a bug in Observables.jl, but my experience with observables has been fairly stable so far. Type conversion systematically happens, or Julia complains.
My MRE is as follows:
This shows a webpage with two sliders. It also ensures the observables (
index1
andindex2
)'s element type isInt
and registers listeners that test whether the type of the input value is anInt
as expected.Clicking on any of the sliders makes the test fail and generates the exact same error message (appart from one line number):
The text was updated successfully, but these errors were encountered: