So I have a bunch of models that output the same plots, with parameter control. I want to be able to swap the models and the controller sliders update. Then using the new sliders should update the plots.
I have it mostly working, but it feels hackish, and I’m not sure how you are intended to do this kind of two-step observation process with observables: the model is observed and rebuilds the widgets, and those widgets then need to be observed.
Here I re-declare the observable mapping inside another mapping function:
function make_sliders(m) # extract data for sliders from the model params = Flatten.flatten(Vector, m) range = Flatten.metaflatten(Vector, m, DynamicEnergyBudgets.range) labels = Flatten.metaflatten(Vector, m, fieldname_meta) # rebuild the sliders for the new model sl = broadcast((x,l,v) -> InteractBase.slider(x:(x-x)/200:x, label=string(l), value=v), range, labels, params) # remap the slider values to another grouped observable map!((x...) -> [x...], sliderobs, throttle.(0.2, observe.(sl))...) # remap slider observations (and checks from elsewhere) to update the plot map!(make_plot, plt, m, checkobs, sliderobs) sl end map!(make_sliders, sliders, model);
But this ends up with a lot of difficult to diagnose bugs, and doesn’t seem right.
Any ideas from people who understand a little more how observables work?