Skip to content

Commit

Permalink
correctly update models in pages, remove handler-deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Nov 27, 2024
1 parent f379a45 commit 4b767ca
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/ReactiveTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,14 @@ macro init(args...)
:($__module__.__GF_AUTO_HANDLERS__)
end
output = quote
$initfn($(init_args...)) |> $handlersfn
local instance = $initfn($(init_args...)) |> $handlersfn

# Update the model in all pages where it has been set as instance of an app.
# Where it has been set as ReactiveModel type, no change is required
for p in Stipple.Pages._pages
p.context == $__module__ && p.model isa $typename && (p.model = instance)
end
instance
end
called_without_type && !isdefined(__module__, typename) && pushfirst!(output.args, :(@eval $__module__ @app))

Expand All @@ -558,7 +565,6 @@ end
macro handlers(expr)
modelname = Symbol(model_typename(__module__))
quote
Stipple.ReactiveTools.delete_handlers!($__module__)
Stipple.ReactiveTools.@handlers $modelname $expr __GF_AUTO_HANDLERS__
end |> esc
end
Expand Down Expand Up @@ -834,8 +840,6 @@ macro onchange(location, vars, expr)

output = [ex]
quote
function __GF_AUTO_HANDLERS__ end
Base.delete_method.(methods(__GF_AUTO_HANDLERS__))
$output[end]
end |> esc
end
Expand Down Expand Up @@ -891,19 +895,9 @@ macro onbutton(location, var, expr)
expr = fieldnames_to_fieldcontent(expr, known_reactive_vars)
expr = unmask(expr, known_vars)

ex = :(onbutton($var) do
:(onbutton($var) do
$(expr.args...)
end)

output = quote end

if loc isa Module
push!(output.args, :(function __GF_AUTO_HANDLERS__ end))
push!(output.args, :(Base.delete_method.(methods(__GF_AUTO_HANDLERS__))))
end
push!(output.args, QuoteNode(ex))

output |> esc
end) |> esc
end

#===#
Expand Down

0 comments on commit 4b767ca

Please sign in to comment.