Skip to content

Commit 5b38d52

Browse files
committed
rename wait_for -> sync
1 parent a1d4cb8 commit 5b38d52

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

NetworkDynamicsInspector/src/NetworkDynamicsInspector.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ function inspect(sol; restart=false, reset=false, display=CURRENT_DISPLAY[])
157157
APPSTATE[] = appstate
158158
CURRENT_WEBAPP[] = webapp
159159

160-
wait_for()
160+
sync()
161161
nothing
162162
end
163163

NetworkDynamicsInspector/src/appstate.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ set_maybe!(obs::Observable, ::NotSpecified) = nothing
9696
Set the solution of the current appstate to `sol`.
9797
"""
9898
function set_sol!(sol)
99-
wait_for()
99+
sync()
100100
if isnothing(APPSTATE[])
101101
APPSTATE[] = AppState(sol)
102102
else
103103
APPSTATE[].sol[] = sol
104104
end
105-
wait_for()
105+
sync()
106106
nothing
107107
end
108108

@@ -117,12 +117,12 @@ function set_state!(; sol = NotSpecified(),
117117
t = NotSpecified(),
118118
tmin = NotSpecified(),
119119
tmax = NotSpecified())
120-
wait_for()
120+
sync()
121121
sol != NotSpecified() && set_sol!(sol)
122122
set_maybe!(appstate().t, t)
123123
set_maybe!(appstate().tmin, tmin)
124124
set_maybe!(appstate().tmax, tmax)
125-
wait_for()
125+
sync()
126126
nothing
127127
end
128128

@@ -139,15 +139,15 @@ function set_graphplot!(; nstate = NotSpecified(),
139139
estate_rel = NotSpecified(),
140140
ncolorrange = NotSpecified(),
141141
ecolorrange = NotSpecified())
142-
wait_for()
142+
sync()
143143
gp = appstate().graphplot
144144
set_maybe!(gp.nstate, nstate)
145145
set_maybe!(gp.estate, estate)
146146
set_maybe!(gp.nstate_rel, nstate_rel)
147147
set_maybe!(gp.estate_rel, estate_rel)
148148
set_maybe!(gp.ncolorrange, ncolorrange)
149149
set_maybe!(gp.ecolorrange, ecolorrange)
150-
wait_for()
150+
sync()
151151
nothing
152152
end
153153

@@ -161,15 +161,15 @@ To automaticially create commands see [`dump_app_state()`](@ref).
161161
function set_timeseries!(key; selcomp = NotSpecified(),
162162
states = NotSpecified(),
163163
rel = NotSpecified())
164-
wait_for()
164+
sync()
165165
if !haskey(appstate().tsplots[], key)
166166
appstate().tsplots[][key] = TimeseriesPlot()
167167
end
168168
tsplot = appstate().tsplots[][key]
169169
set_maybe!(tsplot.selcomp, selcomp)
170170
set_maybe!(tsplot.states, states)
171171
set_maybe!(tsplot.rel, rel)
172-
wait_for()
172+
sync()
173173
nothing
174174
end
175175

@@ -182,7 +182,7 @@ Defines timeseries, where `tsarray` is an array of timeseries keyword arguments
182182
To automaticially create commands see [`dump_app_state()`](@ref).
183183
"""
184184
function define_timeseries!(tsarray)
185-
wait_for()
185+
sync()
186186
if length(tsarray) != length(appstate().tsplots[])
187187
empty!(appstate().tsplots[])
188188
tskeys = [gendomid("ts") for _ in tsarray]
@@ -193,7 +193,7 @@ function define_timeseries!(tsarray)
193193
set_timeseries!(key; tsargs...)
194194
end
195195
notify(appstate().tsplots)
196-
wait_for()
196+
sync()
197197
nothing
198198
end
199199

@@ -205,7 +205,7 @@ commands to recreate the current appstate.
205205
The intended usecase is to quickly recreate "starting points" for interactive exploration.
206206
"""
207207
function dump_app_state(io=stdout)
208-
wait_for()
208+
sync()
209209
println(io, "# To recreate the current state, run the following commands:\n")
210210
println(io, styled"set_sol!({red:sol}) # optional if after inspect(sol)")
211211
println(io, "set_state!(; t=$(appstate().t[]), tmin=$(appstate().tmin[]), tmax=$(appstate().tmax[]))")

NetworkDynamicsInspector/src/serving.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ function get_electron_app end
133133
function get_electron_window end
134134

135135
function save_electron_screenshot(path=joinpath(@__DIR__, "screenshot.png"), resize=true)
136+
sync()
136137
resize && _resize_electron_to_content()
137138

138139
path = isabspath(path) ? path : joinpath(pwd(), path)
@@ -146,7 +147,7 @@ function save_electron_screenshot(path=joinpath(@__DIR__, "screenshot.png"), res
146147
console.log('Screenshot saved to ', screenshotPath);
147148
});
148149
"""
149-
wait_for()
150+
sync()
150151
sleep(3) # make sure that axis updates and so on
151152
d = run(get_electron_app(), js)
152153
while !(isfile(path))
@@ -162,7 +163,7 @@ function _resize_electron_to_content()
162163
let maxHeight = 0;
163164
Array.from(document.querySelectorAll('.graphplot-col, .timeseries-col')).forEach(el => {
164165
const height = el.offsetHeight;
165-
console.log(height)
166+
// console.log("Set new height", height)
166167
if (height > maxHeight) {
167168
maxHeight = height;
168169
}
@@ -176,4 +177,5 @@ function _resize_electron_to_content()
176177
resolution = (oldres[1], y)
177178
CURRENT_DISPLAY[] = ElectronDisp(; resolution)
178179
get_electron_window() # trigger resize
180+
sleep(3)
179181
end

NetworkDynamicsInspector/src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function download_assets()
142142
end
143143
end
144144

145-
function wait_for()
145+
function sync()
146146
isnothing(APPSTATE[]) && return
147147
for cache in values(APPSTATE[]._tsplotscache)
148148
wait_for(cache.plotqueue)

0 commit comments

Comments
 (0)