Skip to content

Commit

Permalink
Merge branch 'master' into hh-extension2
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Oct 17, 2023
2 parents d176fbe + 252b37f commit c6a97fc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Stipple"
uuid = "4acbeb90-81a0-11ea-1966-bdaff8155998"
authors = ["Adrian <[email protected]>"]
version = "0.27.8"
version = "0.27.10"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
4 changes: 3 additions & 1 deletion ext/StippleJSONExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ isdefined(Base, :get_extension) ? using JSON : using ..JSON

# garantee interoperability of different JSONTText definitions in Stipple and JSON
# for both JSON3 and JSON
# Note that `lower` for Stipple.JSONText is not defined as parse(json.s), because that would require
# pure proper JSON. For transmissions of bindings, though, we need to allow to pass object names.

JSON.JSONText(json::Stipple.JSONText) = JSON.JSONText(json.s)
JSON.show_json(io::JSON.Writer.CompactContext, s::JSON.Writer.CS, json::Stipple.JSONText) = write(io, json.s)
JSON.Writer.lower(json::Stipple.JSONText) = JSON.parse(json.s)
JSON.Writer.lower(json::Stipple.JSONText) = json.s

Stipple.JSONText(json::JSON.JSONText) = Stipple.JSONText(json.s)
@inline StructTypes.StructType(::Type{JSON.JSONText}) = JSON3.RawType()
Expand Down
14 changes: 12 additions & 2 deletions src/Stipple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,19 @@ function init(::Type{M};
end

push!(model, field => newval; channel = channel, except = client)
update!(model, field, newval, oldval)

LAST_ACTIVITY[Symbol(channel)] = now()

try
update!(model, field, newval, oldval)
catch ex
# send the error to the frontend
if Genie.Configuration.isdev()
return ex
else
return "An error has occured -- please check the logs"
end
end

ok_response
end
end
Expand Down
26 changes: 22 additions & 4 deletions src/stipple/mutators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,35 @@ function callwatchers(field, val, keys...; notify)

continue
end

# compatibility with Observables 0.5
f = x isa Pair ? x[2] : x

if notify(f)
try
Base.invokelatest(f, val)
catch ex
@error "Error attempting to invoke handler $count for field $field with value $val"
@error "" exception=(ex, catch_backtrace())
Genie.Configuration.isdev() && rethrow(ex)
error_message = """
Error attempting to invoke handler.
Handler:
$(methods(f))
$( code_lowered(f, (typeof(val),)) )
Type of argument:
$((isa(field, Reactive) ? field[] : field) |> typeof)
Value:
$val
Exception:
$ex
"""
@error error_message exception=(ex, catch_backtrace())

rethrow(ex)
end
end

Expand Down

0 comments on commit c6a97fc

Please sign in to comment.