diff --git a/src/ReactiveTools.jl b/src/ReactiveTools.jl index beac94f4..4f4efca2 100644 --- a/src/ReactiveTools.jl +++ b/src/ReactiveTools.jl @@ -252,6 +252,11 @@ macro type() esc(:($type)) end +import Stipple.@clear_cache +macro clear_cache() + :(Stipple.clear_cache(Stipple.@type)) |> esc +end + function update_storage(m::Module) clear_type(m) # isempty(Stipple.Pages._pages) && return diff --git a/src/stipple/reactivity.jl b/src/stipple/reactivity.jl index 8bb87239..c981137e 100644 --- a/src/stipple/reactivity.jl +++ b/src/stipple/reactivity.jl @@ -122,7 +122,7 @@ end """ abstract type ReactiveModel end -export @vars, @add_vars, @define_mixin +export @vars, @add_vars, @define_mixin, @clear_cache, clear_cache # deprecated export @reactive, @reactive!, @old_reactive, @old_reactive! @@ -339,6 +339,16 @@ macro var_storage(expr, new_inputmode = :auto) esc(:($storage)) end +function clear_cache(M::Type{<:ReactiveModel}) + delete!.(Ref(Stipple.DEPS), filter(x -> x isa Type && x <: M, keys(Stipple.DEPS))) + Stipple.Genie.Router.delete!(Symbol(Stipple.routename(M))) + return nothing +end + +macro clear_cache(App) + :(Stipple.clear_cache($(esc(App)))) +end + macro type(modelname, storage) modelname isa DataType && (modelname = modelname.name.name) modelconst = Symbol(modelname, '!')