Skip to content

Commit 11642f5

Browse files
committed
clear nested Observables
1 parent ade211e commit 11642f5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

NetworkDynamicsInspector/src/utils.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,20 @@ function gen_state_options(nw::Network, sidxs)
2727
options
2828
end
2929

30-
function clear_obs!(nt::NamedTuple)
31-
for v in values(nt)
30+
function clear_obs!(x::Union{NamedTuple, AbstractDict})
31+
for v in values(x)
3232
clear_obs!(v)
3333
end
3434
end
35-
clear_obs!(obs::Observable) = empty!(obs.listeners)
35+
function clear_obs!(obs::Observable)
36+
empty!(obs.listeners)
37+
clear_obs!(obs.val)
38+
end
39+
function clear_obs!(v::AbstractVector)
40+
for el in v
41+
clear_obs!(el)
42+
end
43+
end
3644
clear_obs!(x) = x
3745

3846
# TODO: move to grpahmakie

0 commit comments

Comments
 (0)