Skip to content

Commit

Permalink
fixes for JSON3 changes & observables
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Feb 19, 2020
1 parent 1b0661f commit 53dd289
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ JSON3.StructType(::Type{Hyperscript.Node{Hyperscript.HTMLSVG}}) = JSON3.ObjectTy
MsgPack.msgpack_type(::Type{Hyperscript.Node{Hyperscript.HTMLSVG}}) = MsgPack.MapType()

function MsgPack.to_msgpack(::MsgPack.MapType, node::Hyperscript.Node{Hyperscript.HTMLSVG})
return JSON3.keyvaluepairs(node)
return JSON3.StructTypes.keyvaluepairs(node)
end

function JSON3.keyvaluepairs(node::Hyperscript.Node{Hyperscript.HTMLSVG})
function JSON3.StructTypes.keyvaluepairs(node::Hyperscript.Node{Hyperscript.HTMLSVG})
return [
:tag => getfield(node, :tag),
:children => getfield(node, :children),
Expand Down
7 changes: 2 additions & 5 deletions src/widgets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,10 @@ struct Slider{T <: AbstractRange, ET} <: AbstractWidget{T}
attributes::Dict{Symbol, Any}
end

to_node(x) = Observable(x)
to_node(x::Observable) = x

function Slider(range::T, value = first(range); kw...) where T <: AbstractRange
Slider{T, eltype(range)}(
to_node(range),
to_node(value),
convert(Observable, range),

This comment has been minimized.

Copy link
@yakir12

yakir12 Feb 24, 2020

Contributor

@SimonDanisch This here doesn't seem to work:

julia> convert(Observable, 1:2)
ERROR: MethodError: Cannot `convert` an object of type UnitRange{Int64} to an object of type Observable
Closest candidates are:
  convert(::Type{T}, ::T) where T at essentials.jl:168
  Observable(::T) where T at /home/yakir/.julia/packages/Observables/qCJWB/src/Observables.jl:27
Stacktrace:
 [1] top-level scope at REPL[7]:1

at least for the latest release of Observables v0.2.3. In fact, you can't seem to convert anything into an Observable like that. You have to wrap it in an Observable:

julia> Observable(1:2)
Observable{UnitRange{Int64}} with 0 listeners. Value:
1:2

Sorry, I'm sure you know this. I might be missing something.

This comment has been minimized.

Copy link
@SimonDanisch

SimonDanisch Feb 24, 2020

Author Owner

Hm, that's me getting ready for: JuliaGizmos/Observables.jl#40
But it hasn't been merged yet, and guess I haven't been hitting that case in my code + tests -.-

This comment has been minimized.

Copy link
@yakir12

yakir12 Feb 24, 2020

Contributor

Not hitting this? By not using Slider and other widgets at all? Will it be ok if I ping that PR as a show of interest as well, or is that a fou pas?

This comment has been minimized.

Copy link
@SimonDanisch

SimonDanisch Feb 24, 2020

Author Owner

In any case, this should be fixed on the newest version ;) Moved the widgets finally to https://github.com/JuliaGizmos/WidgetsBase.jl, which fixes this issue!

convert(Observable, value),
Dict{Symbol, Any}(kw)
)
end
Expand Down

0 comments on commit 53dd289

Please sign in to comment.