Skip to content

Commit

Permalink
add clear_cache() and @clear_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Sep 8, 2023
1 parent 0ab7770 commit f780552
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/ReactiveTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion src/stipple/reactivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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, '!')
Expand Down

0 comments on commit f780552

Please sign in to comment.